cartodb-4.42/app/models/carto/helpers/multifactor_authentication.rb
2024-04-06 05:25:13 +00:00

24 lines
684 B
Ruby

module Carto::MultifactorAuthentication
MULTIFACTOR_AUTHENTICATION_ENABLED = 'enabled'.freeze
MULTIFACTOR_AUTHENTICATION_DISABLED = 'disabled'.freeze
MULTIFACTOR_AUTHENTICATION_NEEDS_SETUP = 'setup'.freeze
def multifactor_authentication_configured?
user_multifactor_auths.any?
end
def active_multifactor_authentication
user_multifactor_auths.order(created_at: :desc).first
end
def multifactor_authentication_status
if user_multifactor_auths.setup.any?
MULTIFACTOR_AUTHENTICATION_NEEDS_SETUP
elsif user_multifactor_auths.enabled.any?
MULTIFACTOR_AUTHENTICATION_ENABLED
else
MULTIFACTOR_AUTHENTICATION_DISABLED
end
end
end