Class: ProductionUser

Inherits:
User
  • Object
show all
Defined in:
lib/models/production_user.rb

Overview

because user passwords are hashed both on a production server, and locally, a random salt can’t be added to the password. clients will send the hashed version of the password, so a simple comparison to the stored password is ok.

Instance Method Summary collapse

Instance Method Details

#create_salt_and_hash_passwordObject



5
6
7
# File 'lib/models/production_user.rb', line 5

def create_salt_and_hash_password
  self.password_salt = nil
end

#hash_passwordObject



9
10
11
12
# File 'lib/models/production_user.rb', line 9

def hash_password
  return unless password_changed? && password?
  self.password = Password.hashed_password(nil, password)
end

#passwords_match?(password) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/models/production_user.rb', line 14

def passwords_match?(password)
  self.password_was == password ? self : nil
end