I am using devise as my authentication system. And i want to
authenticate user with username along with subdomain.
It seems that devise needs both the username and subdomain field in
the same table which is not in my case.
I have subdomain field in Company table while username and password in
the UserAccount table.
And there is references_many relation between UserAccount and Company table
Now how can i authenticate the user with both username and subdomain
Please help me out.
!#user.rb
devise :all, :authentication_keys => [:email, :subdomain]
OR
!#config/initializer/devise.rb
Devise.setup do |config|
config.authentication_keys = [ :email, :subdomain ]
end
!#login.erb.html
...
f.hidden_field :subdomain, :value => current_subdomain
...
!#user.rb
def self.find_for_authentication(conditions={})
find(:first, :conditions => { :companies => { :subdomain => conditions.delete(:subdomain) } }, :joins => :companies)
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With