~cytrogen/masto-fe

ref: 2f8f92df48326c7ae61679773e64afca46d9a374 masto-fe/app/controllers/settings/two_factor_authentication_methods_controller.rb -rw-r--r-- 703 bytes
2f8f92df — Matt Jankowski Fix Elastic check deprecation warning about gem version (#27262) 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

module Settings
  class TwoFactorAuthenticationMethodsController < BaseController
    include ChallengableConcern

    skip_before_action :require_functional!

    before_action :require_challenge!, only: :disable
    before_action :require_otp_enabled

    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