module PastaRails::InstanceMethodsOnActivation

Attributes

password[R]

Public Instance Methods

authenticate(unencrypted_password) click to toggle source
# File lib/pasta_rails.rb, line 14
def authenticate(unencrypted_password)
  @password_digest = self.password_digest
  res, new_hash = Pasta.verify_password_update_hash(@password_digest, unencrypted_password)
  if res
      # Want to avoid database transaction if possible
      if !new_hash.eql? @password_digest
        self.update password_digest: new_hash
      end
      self
  else
      false
  end
end
password=(unencrypted_password) click to toggle source
# File lib/pasta_rails.rb, line 30
def password=(unencrypted_password)
  if unencrypted_password.nil?
    self.password_digest = nil
  elsif !unencrypted_password.empty?
    self.password_digest = Pasta.hash_password(unencrypted_password)
  end
end
password_confirmation=(unencrypted_password) click to toggle source
# File lib/pasta_rails.rb, line 38
def password_confirmation=(unencrypted_password)
  @password_confirmation = unencrypted_password
end