0
votes

I have a User model and an admin model and I am using devise for authentication. My Admin logins using an email and password. My User can login using both email and username. What should my

#config/initializers/devise.rb
config.authentication_keys = [ : ]

line should be and do I need to override devise to achieve this ?

1
Check out the wiki on devise, there is an article with this github.com/plataformatec/devise/wiki/… - kurenn

1 Answers

0
votes

Is email a required field for the User? If so, you can overwrite the Devise SessionController locate the user's email if username is used and process the authentication.

I would also STRONGLY advise against having a separate User and Admin model, unless Admin inherits User. You are only asking for problems in user management. I would recommend setting a role[s] attribute on the User model and using a framework like Pundit to manage access policy.