Class: Admin::SecurityController
Instance Attribute Summary
#cache, #pagination_parameters, #trusty_config
Instance Method Summary
collapse
#after_sign_in_path_for, #initialize, #template_name
included
Instance Method Details
#disable_two_factor ⇒ Object
39
40
41
42
43
44
45
46
|
# File 'app/controllers/admin/security_controller.rb', line 39
def disable_two_factor
if @user.update(otp_required_for_login: false, otp_secret: nil)
redirect_to admin_security_path, notice: t('security_controller.two_factor_disabled')
else
flash[:error] = t('security_controller.two_factor_disabled_error')
redirect_to admin_security_path
end
end
|
#edit ⇒ Object
15
16
17
|
# File 'app/controllers/admin/security_controller.rb', line 15
def edit
render
end
|
#show ⇒ Object
10
11
12
13
|
# File 'app/controllers/admin/security_controller.rb', line 10
def show
set_standard_body_style
render :edit
end
|
#update ⇒ Object
19
20
21
22
23
24
25
26
27
|
# File 'app/controllers/admin/security_controller.rb', line 19
def update
if @user.update(security_params)
sign_out(@user)
redirect_to new_user_session_path, notice: t('security_controller.password_updated')
else
flash[:error] = t('security_controller.error_updating_password')
render :edit
end
end
|
#verify_two_factor ⇒ Object
29
30
31
32
33
34
35
36
37
|
# File 'app/controllers/admin/security_controller.rb', line 29
def verify_two_factor
if @user.validate_and_consume_otp!(params[:otp_attempt])
@user.update!(otp_required_for_login: true)
redirect_to admin_security_path, notice: t('security_controller.two_factor_enabled')
else
flash[:error] = t('security_controller.two_factor_invalid_code')
redirect_to admin_security_path
end
end
|