Module: Merb::Authentication::Mixins::SaltedUserWithAccount::DMClassMethods
- Defined in:
- lib/heedley-merb-auth-with-account/mixins/salted_user/dm_salted_user_with_account.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#authenticate(login, password, account_name = nil) ⇒ Object
self.extended.
Class Method Details
.extended(base) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/heedley-merb-auth-with-account/mixins/salted_user/dm_salted_user_with_account.rb', line 5 def self.extended(base) base.class_eval do property :crypted_password, String property :salt, String belongs_to :account validates_present :password, :if => proc{|m| m.password_required?} validates_is_confirmed :password, :if => proc{|m| m.password_required?} before :save, :encrypt_password end # base.class_eval end |
Instance Method Details
#authenticate(login, password, account_name = nil) ⇒ Object
self.extended
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/heedley-merb-auth-with-account/mixins/salted_user/dm_salted_user_with_account.rb', line 19 def authenticate(login, password, account_name = nil) if account_name.nil? || account_name.empty? Merb.logger.error "User.authenticate MISSING account_name!" return nil end @account = Account.find_by_title(account_name) if @account.nil? Merb.logger.error "User.authenticate account NOT FOUND" return nil end @u = first( Merb::Authentication::Strategies::Basic::Base.login_param => login, :account_id => @account.id ) @u && @u.authenticated?(password, account_name) ? @u : nil end |