views:

27

answers:

1

Typically, with Authlogic, you would authenticate with some unique identifier (e.g. email or username) and a password. Authlogic does this by first finding the record by the identifier (User.find_by_email_address(email) or similar), then calling then .authenticate method on the returned object, which checks the password against the record.

What I want to do is change the way Authlogic finds the record (at a finer level than just changing the field it uses). My use case requires that the email_address column (in this case) is in an associated child model.

Essentially, I want to ask Authlogic to find my User record based on the presence of an associated Subscriber model that is uniquely identified by the email_address that is provided.

Has anyone seen Authlogic accommodate this?

A: 

You might probably want to configure a different #login_field.

Simone Carletti
`#login_field` only accepts a symbol for another field in the DB, not for one in an associated model. It's looking more like I'll need to re-define the method that does the finding.
bjeanes
Does it want a field in the db or a method? If it only cares about a method (you need to check the source code), then you can simply creates a method that returns the result of the association.
Simone Carletti
it needs a field. It does find_by_xyz() on the main User record. I may need to find that exact method and override it to do a find with a join and use conditions on the associated record.
bjeanes