Module: Devise::Models::Stretchable

Extended by:
ActiveSupport::Concern
Defined in:
lib/devise/async/stretch/model.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.required_fields(klass) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/devise/async/stretch/model.rb', line 12

def self.required_fields(klass)
  if Devise::Async::Stretch.enabled
    klass.authentication_keys
  else
    [:encrypted_password] + klass.authentication_keys
  end
end

Instance Method Details

#authenticatable_saltObject

This is used in the session, used to verify if the password has changed



27
28
29
# File 'lib/devise/async/stretch/model.rb', line 27

def authenticatable_salt
  stretch_mark if stretch_mark
end

#bcrypt(password, stretches = nil) ⇒ Object

Our own bcrypt mehtod which supports arbitrary stretches



21
22
23
24
# File 'lib/devise/async/stretch/model.rb', line 21

def bcrypt(password, stretches=nil)
  stretches ||= self.class.stretches
  ::BCrypt::Password.create("#{password}#{self.class.pepper}", cost: stretches).to_s
end