Class: Decidim::Admin::ManagedUsersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/decidim/admin/managed_users_controller.rb

Overview

Controller that allows managing managed users at the admin panel.

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_ability_klass, #user_not_authorized_path

Instance Method Details

#createObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/controllers/decidim/admin/managed_users_controller.rb', line 38

def create
  authorize! :create, :managed_users

  @form = form(ManagedUserForm).from_params(params)

  CreateManagedUser.call(@form) do
    on(:ok) do
      flash[:notice] = I18n.t("managed_users.create.success", scope: "decidim.admin")
      redirect_to decidim.root_path
    end

    on(:invalid) do
      flash.now[:alert] = I18n.t("managed_users.create.error", scope: "decidim.admin")
      render :new
    end
  end
end

#indexObject



16
17
18
19
# File 'app/controllers/decidim/admin/managed_users_controller.rb', line 16

def index
  authorize! :index, :managed_users
  @managed_users = collection.page(params[:page]).per(15)
end

#newObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/decidim/admin/managed_users_controller.rb', line 21

def new
  authorize! :new, :managed_users

  if available_authorization_handlers.blank?
    flash[:alert] = I18n.t("managed_users.new.no_authorization_handlers", scope: "decidim.admin")
    redirect_to action: :index
  end

  unless select_authorization_handler_step?
    @form = form(ManagedUserForm).from_params(
      authorization: {
        handler_name: handler_name
      }
    )
  end
end