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)


167
168
169
# File 'lib/sorcery/model.rb', line 167

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.



161
162
163
# File 'lib/sorcery/model.rb', line 161

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)


172
173
174
175
176
177
178
179
# File 'lib/sorcery/model.rb', line 172

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

  salt = send(sorcery_config.salt_attribute_name) unless sorcery_config.salt_attribute_name.nil?

  sorcery_config.encryption_provider.matches?(crypted, pass, salt)
end