Module: Sequel::Plugins::SequelAuth::InstanceMethods

Defined in:
lib/sequel_auth.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



49
50
51
# File 'lib/sequel_auth.rb', line 49

def password
  @password
end

#password_confirmationObject

Returns the value of attribute password_confirmation.



48
49
50
# File 'lib/sequel_auth.rb', line 48

def password_confirmation
  @password_confirmation
end

Instance Method Details

#authenticate(unencrypted) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/sequel_auth.rb', line 55

def authenticate(unencrypted)
  if model.provider.matches?(self.send(model.digest_column),unencrypted)
    if model. || model.
      #Update login count
      self.send("#{model.}=",self.send(model.)+1 ) if model.
      self.send("#{model.}=",Time.now ) if model.
      self.save
    end
    self
  else
    if model.
      #Update failed login count
      self.send("#{model.}=",self.send(model.)+1 )
      self.save            
    end
  end
end

#reset_access_tokenObject



73
74
75
76
77
# File 'lib/sequel_auth.rb', line 73

def reset_access_token
  if model.access_token_column
    self.update(model.access_token_column=>SecureRandom.urlsafe_base64(16))
  end
end

#validateObject



79
80
81
82
83
84
85
86
# File 'lib/sequel_auth.rb', line 79

def validate
  super
  
  if model.include_validations
    errors.add :password, 'is not present'              if password.nil? && new?
    errors.add :password, 'doesn\'t match confirmation' if password != password_confirmation
  end
end