Class: Admin::UsersController
Instance Attribute Summary
#cache, #pagination_parameters, #trusty_config
Instance Method Summary
collapse
#destroy, #index, model_class, paginate_models, #paginated?, #pagination_parameters, #will_paginate_options
#create_responses, extended
#after_sign_in_path_for, #initialize, #template_name
included
Instance Method Details
#create ⇒ Object
15
16
17
18
19
20
21
22
23
24
|
# File 'app/controllers/admin/users_controller.rb', line 15
def create
user = User.new(user_params)
if user.save
flash[:notice] = 'User was created.'
redirect_to admin_users_path
else
flash[:error] = 'There was an error saving the user. Please try again.'
render :new
end
end
|
#disable_2fa ⇒ Object
48
49
50
51
52
53
54
55
|
# File 'app/controllers/admin/users_controller.rb', line 48
def disable_2fa
user = User.find(params[:id])
user.update(
otp_required_for_login: false,
otp_secret: nil,
)
redirect_to admin_users_path
end
|
#ensure_deletable ⇒ Object
41
42
43
44
45
46
|
# File 'app/controllers/admin/users_controller.rb', line 41
def ensure_deletable
if current_user.id.to_s == params[:id].to_s
announce_cannot_delete_self
redirect_to admin_users_path
end
end
|
#show ⇒ Object
11
12
13
|
# File 'app/controllers/admin/users_controller.rb', line 11
def show
redirect_to edit_admin_user_path(params[:id])
end
|
#update ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'app/controllers/admin/users_controller.rb', line 26
def update
user_params = params[model_symbol].permit!
if user_params && user_params['admin'] == false && model == current_user
user_params.delete('admin')
announce_cannot_remove_self_from_admin_role
end
model.skip_password_validation = true unless user_params[:password_confirmation].present?
if model.update(user_params)
response_for :update
else
flash[:error] = 'There was an error saving the user. Please try again.'
render :edit
end
end
|