Module: Devise::Models::TwoFactorAuthenticatable::ClassMethods

Defined in:
lib/two_factor_authentication/models/two_factor_authenticatable.rb

Instance Method Summary collapse

Instance Method Details

#has_one_time_password(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/two_factor_authentication/models/two_factor_authenticatable.rb', line 8

def has_one_time_password(options = {})

  cattr_accessor :otp_column_name
  self.otp_column_name = "otp_secret_key"

  include InstanceMethodsOnActivation

  before_create { populate_otp_column }

  if respond_to?(:attributes_protected_by_default)
    def self.attributes_protected_by_default #:nodoc:
      super + [self.otp_column_name]
    end
  end
end