add force 2fa toggle

This commit is contained in:
Pete Matsyburka
2023-12-02 01:50:54 +02:00
parent a87ca65839
commit 489f9859be
9 changed files with 93 additions and 29 deletions
+20
View File
@@ -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