Browse Source

Update two_factor_authenticatable.rb

pull/2/head
Recker Swartz 3 years ago committed by GitHub
parent
commit
fc88ef7ed6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      lib/two_factor_authentication/models/two_factor_authenticatable.rb

13
lib/two_factor_authentication/models/two_factor_authenticatable.rb

@ -52,11 +52,16 @@ module Devise
def provisioning_uri(account = nil, options = {}) def provisioning_uri(account = nil, options = {})
totp_secret = options[:otp_secret_key] || otp_secret_key totp_secret = options[:otp_secret_key] || otp_secret_key
options[:digits] ||= options[:otp_length] || self.class.otp_length options[:digits] ||= options[:otp_length] || self.class.otp_length
raise "provisioning_uri called with no otp_secret_key set" if totp_secret.nil? raise 'provisioning_uri called with no otp_secret_key set' if totp_secret.nil?
account ||= email if respond_to?(:email) account ||= email if respond_to?(:email)
options[:issuer] ||= options[:issuer_name] unless options[:issuer_name].blank? options[:issuer] ||= self.class.issuer_name if self.class.issuer_name.present?
options[:image] ||= options[:logo_url] unless options[:logo_url].blank? if self.class.logo_url.blank?
ROTP::TOTP.new(totp_secret, options).provisioning_uri(account) ROTP::TOTP.new(totp_secret, options).provisioning_uri(account)
else
image = "&image=#{self.class.logo_url}"
ROTP::TOTP.new(totp_secret, options).provisioning_uri(account) + image
end
end end
def need_two_factor_authentication?(request) def need_two_factor_authentication?(request)

Loading…
Cancel
Save