I installed Devise (on Rails 3) to use Basecamp-style subdomain authentication. Under this model, a user can be registered twice in different subdomains with the same email address.
For instance:
class User < ActiveRecord::Base belongs_to :account end class Account < ActiveRecord::Base
User 1 is registered on company1.myapp.com with an email address bob@acme.com
User 2 is registered on company2.myapp.com with an email address bob@acme.com
(Both users are managed by the same person, but belong to different subdomains.)
Logging in works fine, but the standard Reset password only looks at the email address, so you can only reset the password for user 1 . What I would like to do is to consider the subdomain of the request, so the Reset password from company2.myapp.com/password/new will be Reset password for user 2 .
The developer is looking for a user using the find_first method, which I think does not accept joining, so I cannot include the condition :account => {:subodmain => 'comapny2'} .
I can override send_reset_password_instructions to manually search for a user record, but it feels hacked, and I will need to do this for send_confirmation_instructions .
Is there a better way?
source share