disable 2FA according to config

2FA is disabled for superadmin unless `SUPER_ADMIN_OTP_ENABLED` is equal
to `enabled` (default value)
This commit is contained in:
Christophe Robillard 2023-03-02 13:47:48 +01:00
parent ef970dbfe5
commit 6af01077b6
3 changed files with 10 additions and 5 deletions

View file

@ -27,8 +27,12 @@
class SuperAdmin < ApplicationRecord
include PasswordComplexityConcern
devise :rememberable, :trackable, :validatable, :lockable, :recoverable,
:two_factor_authenticatable, :otp_secret_encryption_key => Rails.application.secrets.otp_secret_key
devise :rememberable, :trackable, :validatable, :lockable, :recoverable
if SUPER_ADMIN_OTP_ENABLED
devise :two_factor_authenticatable, :otp_secret_encryption_key => Rails.application.secrets.otp_secret_key
else
devise :database_authenticatable
end
def enable_otp!
self.otp_secret = SuperAdmin.generate_otp_secret