mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-05 17:31:12 +00:00
28 lines
570 B
Ruby
28 lines
570 B
Ruby
# frozen_string_literal: true
|
|
|
|
module MfaForceConcern
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
prepend_before_action :check_mfa_requirement, if: :user_signed_in?
|
|
end
|
|
|
|
private
|
|
|
|
def check_mfa_requirement
|
|
return unless mfa_force_enabled?
|
|
return if current_user.otp_enabled?
|
|
|
|
flash[:alert] = I18n.t('require_multi_factor_auth.required_message')
|
|
redirect_to settings_otp_authentication_path
|
|
end
|
|
|
|
def mfa_force_enabled?
|
|
mfa_config[:force_enabled]
|
|
end
|
|
|
|
def mfa_config
|
|
@mfa_config ||= Rails.application.config_for(:mfa)
|
|
end
|
|
end
|