Devise multiple login pages!

Asked

Viewed 135 times

2

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

My idea is to create a view by taking the email and password and passing it to a Custom controller inheriting from Devise::Sessions and overwrite the method that performs Login, searching 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 for this?

  • Couldn’t you do a unique authentication and do this direction depending on the responsibility of each actor in the system? That is, you will use a single template that can be admin, dev or manager.

1 answer

1

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

From there it is only business rule and pull relationship. I hope it has been clear.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.