views:

111

answers:

2

I've got a typical Authlogic setup that I need to enhance to require Customer ID in addition to Login and Password.

I've read a bit about using a custom find method and another about using a global variable for accessing the additional parameter and a third referring to documentation about using scopes that doesn't seem to exist.

Seems like this should be easy, but I can't seem to find the right approach.

Anyone got a solution?

A: 

Add a customer_id column through a migration and validate_presence_of :customer_id on your model. It doesn't have anything to do with authlogic. Unless there is more that you are trying to do.

bobbywilson0
+1  A: 

In your UserSession class, add:

find_by_login_method :find_by_customer_id_or_login

In your User class, create this customer finder:

def self.find_by_customer_id_or_login(login)
  User.find_by_customer_id(login) || User.find_by_login(login)
end

This is assuming a User has both a customer_id field and a login field.

Nick Stamas