I would suggest you to create a new model SecondaryEmail
.
A User
can has_many :secondary_emails
, and each SecondaryEmail
belongs_to :user
.
You will have to add the validation of uniqueness for each email in SecondaryEmail
, and further, will have to make sure that no new SecondaryEmail is already a primary email of any User.
Provide the interface, so that a User
can add his secondary_emails, with those validations.
Next step will be overriding the SessionController
of Devise.
Upon any login procedure, set up your login procedure for SecondaryEmail.where(:email => params[:email])
whenever an email is not found in User's primary emails. If it exists, authenticate with that user's password, else, user doesn't exist.
This is what I came up with so far. I would really love to know the experts' view and approach in this. :)