Devise multiple login pages!

2

I'm using Devise to authenticate myself. But I have 3 profile types, and I created it through the command rails g devise MODEL my users (Admim, dev and manager), but Devise created a login page for each type of profile, I would like to unify and log in using only one page! .

My idea is to create a view by picking up the email and password and passing it on to a Custom controller inheriting from Devise::Sessions and overwriting the method that logs in, searching for the email in the 3 tables and redirecting the user to Controller responsible for his profile.

How could I do this "manual login" with Devise? Any other solution to this?

    
asked by anonymous 01.06.2017 / 13:18

1 answer

1

One strategy I use is to create a User (responsible for authentication) model and a Profile model that contains the profile data. Then you make a relationship between User has_one Profile and Profile you add a kind field with the profile type ( admin , dev , gerente ).

From there it's just business rule and pull the relationship. I hope it has become clear.

    
02.06.2017 / 13:35