two_factor_authentication_methods_controller.rb 703 B

123456789101112131415161718192021222324252627
  1. # frozen_string_literal: true
  2. module Settings
  3. class TwoFactorAuthenticationMethodsController < BaseController
  4. include ChallengableConcern
  5. skip_before_action :require_functional!
  6. before_action :require_challenge!, only: :disable
  7. before_action :require_otp_enabled
  8. def index; end
  9. def disable
  10. current_user.disable_two_factor!
  11. UserMailer.two_factor_disabled(current_user).deliver_later!
  12. redirect_to settings_otp_authentication_path, flash: { notice: I18n.t('two_factor_authentication.disabled_success') }
  13. end
  14. private
  15. def require_otp_enabled
  16. redirect_to settings_otp_authentication_path unless current_user.otp_enabled?
  17. end
  18. end
  19. end