Module: Sorcery::Model::InstanceMethods

Defined in:
lib/sorcery/model.rb

Instance Method Summary collapse

Instance Method Details

#external?Boolean

identifies whether this user is regular, i.e. we hold his credentials in our db, or that he is external, and his credentials are saved elsewhere (twitter/facebook etc.).

Returns:

  • (Boolean)


145
146
147
# File 'lib/sorcery/model.rb', line 145

def external?
  send(sorcery_config.crypted_password_attribute_name).nil?
end

#sorcery_configObject

Returns the class instance variable for configuration, when called by an instance.



139
140
141
# File 'lib/sorcery/model.rb', line 139

def sorcery_config
  self.class.sorcery_config
end

#valid_password?(pass) ⇒ Boolean

Calls the configured encryption provider to compare the supplied password with the encrypted one.

Returns:

  • (Boolean)


150
151
152
153
154
155
156
157
# File 'lib/sorcery/model.rb', line 150

def valid_password?(pass)
  _crypted = self.send(sorcery_config.crypted_password_attribute_name)  
  return _crypted == pass if sorcery_config.encryption_provider.nil?

  _salt = self.send(sorcery_config.salt_attribute_name) unless sorcery_config.salt_attribute_name.nil?

  sorcery_config.encryption_provider.matches?(_crypted, pass, _salt)
end