Module: Hydra::RoleManagement::UserRolesBehavior

Extended by:
ActiveSupport::Concern
Included in:
UserRolesController
Defined in:
app/controllers/concerns/hydra/role_management/user_roles_behavior.rb

Overview

Module defining Controller actions for adding and managing Roles for Users

Instance Method Summary collapse

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/concerns/hydra/role_management/user_roles_behavior.rb', line 13

def create
  authorize! :add_user, @role
  u = find_user
  if u
    u.roles << @role
    u.save!
    redirect_to role_management.role_path(@role)
  else
    redirect_to role_management.role_path(@role),
                flash: { error: "Invalid user #{params[:user_key]}" }
  end
end

#destroyObject



26
27
28
29
30
# File 'app/controllers/concerns/hydra/role_management/user_roles_behavior.rb', line 26

def destroy
  authorize! :remove_user, @role
  @role.users.delete(::User.find(params[:id]))
  redirect_to role_management.role_path(@role)
end