Rails Authlogic authentication method
        Posted  
        
            by Rabbott
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Rabbott
        
        
        
        Published on 2010-04-22T23:45:35Z
        Indexed on 
            2010/04/26
            19:13 UTC
        
        
        Read the original article
        Hit count: 213
        
ruby-on-rails
|authlogic
Within Authlogic, is there a way that I can add conditions to the authentication method? I know by using the find_by_login_method I can specify another method to use, but when I use this I need to pass another parameter since the find_by_login_method method only passes the parameter that is deemed the 'login_field'.
What I need to do is check something that is an association of the authentic model.. Here is the method I want to use
  # make sure that the user has access to the subdomain that they are 
  # attempting to login to, subdomains are company names
  def self.find_by_email_and_company(email, company)
    user = User.find_by_email(email)
    companies = []
    user.brands.each do |b|
      companies << b.company.id
    end
    user && companies.include?(company)
  end
But this fails due to the fact that only one parameter is sent to the find_by_email_and_company method.
The company is actually the subdomain, so in order to get it here I am just placing it in a hidden field in the form (only way I could think to get it to the model)
Is there a method I can override somehow..?
© Stack Overflow or respective owner