# Authlogic - Authentication with 2 login fields

**URL:** <https://www.ruby-forum.com/t/authlogic-authentication-with-2-login-fields/180101>\
**Category:** Rails\
**Created:** [December 11, 2009, 4:02pm UTC](https://www.ruby-forum.com/t/authlogic-authentication-with-2-login-fields/180101 "2009-12-11T16:02:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [December 11, 2009, 4:02pm UTC](https://www.ruby-forum.com/t/authlogic-authentication-with-2-login-fields/180101/1 "2009-12-11T16:02:24Z")

</div>

Hello

I need to authenticate a user based on two database fields living in  
two different tables.

So far I have:  
class UserSession \< Authlogic::Session::Base  
…  
login\_field :employee\_code # the login  
attr\_accessor :employer\_code # the extra login field  
…  
find\_by\_login\_method :find\_app\_user

# must find the employer first, and then the employee

end

However, only the employee is passed to the find\_app\_user method on  
save.

Any tips are appreciated.

Dave
