Module: Merb::Authentication::Mixins::SaltedUser::MongoidClassMethods
- Defined in:
- lib/merb-auth-more/mixins/salted_user/mongoid_salted_user.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#authenticate(login, password) ⇒ Object
self.extended.
Class Method Details
.extended(base) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/merb-auth-more/mixins/salted_user/mongoid_salted_user.rb', line 5 def self.extended(base) base.class_eval do field :crypted_password, :type => String if Merb::Authentication::Mixins::SaltedUser > base field :salt, :type => String end validates_presence_of :password, :if => proc{|m| m.password_required?} validates_confirmation_of :password, :if => proc{|m| m.password_required?} before_save :encrypt_password end # base.class_eval end |
Instance Method Details
#authenticate(login, password) ⇒ Object
self.extended
22 23 24 25 |
# File 'lib/merb-auth-more/mixins/salted_user/mongoid_salted_user.rb', line 22 def authenticate(login, password) @u = first(:conditions => { Merb::Authentication::Strategies::Basic::Base.login_param => login }) @u && @u.authenticated?(password) ? @u : nil end |