开发者

about user authentication with username and subdomain

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开发者_StackOverflow 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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜