Module: UsersAuthentication::ClassMethods
- Defined in:
- lib/generators/fetty/authentication/templates/lib/users_authentication.rb
Instance Method Summary collapse
Instance Method Details
#activate!(id, token) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/generators/fetty/authentication/templates/lib/users_authentication.rb', line 16 def activate!(id,token) user = first(:conditions => { :id => id, :token => token }) case when user.nil? then return UsersAuthentication::Status::Unexist when user.activated? then return UsersAuthentication::Status::Activated else user.update_attribute(:activated_at, Time.now.utc) user.clear_token! return user end end |
#authenticate!(login, pass) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/generators/fetty/authentication/templates/lib/users_authentication.rb', line 5 def authenticate!(login, pass) user = first(:conditions => { :username => login }) || first(:conditions => { :email => login }) case when user.nil? then return UsersAuthentication::Status::Unexist when !user.password_match?(pass) then return UsersAuthentication::Status::InvalidPassword when !user.activated? then return UsersAuthentication::Status::Inactivated else return user end end |