About user authentication with username and subdomain

I use the device as my authentication system. And I want to authenticate the user with the username along with the subdomain. It seems that the developer needs both the username field and the subdomain in the same table, which is not in my case.
I have a subdomain field in the company table, while the username and password in the UserAccount table.
And there are value_references between the UserAccount and Company table Now, how can I authenticate the user with username and subdomain

Please help me.

+4
source share
1 answer
!#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 
+9
source

Source: https://habr.com/ru/post/1316404/


All Articles