Search code examples
ruby-on-railscontrolleradmin

Rails | Should use user model or create another one for admin


I have an user model and authentication handled in session & user controller.

I would like to create a call center pannel. In here i think to create call_center scope as routes. Also CallCenter model to hold the call center person login creditentials. Role model is also needed to check the permissions.

Should i create another session controller to not to bloat current one or can i use current sessions controller to handle auth?


Solution

  • Given the limited amount of information you gave you have the following options:

    1.If you have a lot of logic that will be shared between the standard authentication and the CallCenter one, then your best bet is to use the same controller and have the logic in there, but make sure you don't use too many if's (that will let you know that you don't have that much shared logic, just similar).

    2.Create another controller for call center but have all the shared logic in a class that is used by both the Session, User and CallCenter controllers (something like Authenticator).

    3.Use a well established solution for authentication like devise