diff options
author | Starfall <us@starfall.systems> | 2020-08-31 12:28:25 -0500 |
---|---|---|
committer | Starfall <us@starfall.systems> | 2020-08-31 12:28:25 -0500 |
commit | c5bb91194f0df90ea9c59ea6af1bd985b295fb30 (patch) | |
tree | 47b303b2c64ff1920fb19d01093a08dc9fd20ac8 /app/controllers/settings/two_factor_authentication_methods_controller.rb | |
parent | 27ee0fc8c4c13c53f81ca3db781b9d0783b877e5 (diff) | |
parent | f715e8b51612820a18fa307e4465eb0c1a088f86 (diff) |
Merge branch 'glitch' into main
Diffstat (limited to 'app/controllers/settings/two_factor_authentication_methods_controller.rb')
-rw-r--r-- | app/controllers/settings/two_factor_authentication_methods_controller.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/app/controllers/settings/two_factor_authentication_methods_controller.rb b/app/controllers/settings/two_factor_authentication_methods_controller.rb new file mode 100644 index 000000000..224d3a45c --- /dev/null +++ b/app/controllers/settings/two_factor_authentication_methods_controller.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +module Settings + class TwoFactorAuthenticationMethodsController < BaseController + include ChallengableConcern + + layout 'admin' + + before_action :authenticate_user! + before_action :require_challenge!, only: :disable + before_action :require_otp_enabled + + skip_before_action :require_functional! + + def index; end + + def disable + current_user.disable_two_factor! + UserMailer.two_factor_disabled(current_user).deliver_later! + + redirect_to settings_otp_authentication_path, flash: { notice: I18n.t('two_factor_authentication.disabled_success') } + end + + private + + def require_otp_enabled + redirect_to settings_otp_authentication_path unless current_user.otp_enabled? + end + end +end |