add force 2fa toggle
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class MfaForceController < ApplicationController
|
||||
before_action :load_account_config
|
||||
authorize_resource :account_config
|
||||
|
||||
def create
|
||||
@account_config.update!(value: !@account_config.value)
|
||||
|
||||
redirect_back fallback_location: settings_users_path,
|
||||
notice: "Force 2FA has been #{@account_config.value ? 'enabled' : 'disabled'}."
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_account_config
|
||||
@account_config =
|
||||
AccountConfig.find_or_initialize_by(account: current_account, key: AccountConfig::FORCE_MFA)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user