Reputation: 11
I want to create a webpage using rails 6.0.0, which has two types of users(model) without devise gem. Admin User/viewer
But the problems is that I want to authenticate (sign up /sign in) for both users with facebook or google_oauth2 with same callbacks address without devise gem: /auth/:provider/callback
On internet, github and youtube I have found articles and videos only for authenticate single model. But I want to authenticate (sign up /sign in) for two models.
Can anyone help? Please give an idea to authenticate both model with some example without devise gem that an beginner can understand.
Upvotes: 1
Views: 248
Reputation: 2715
Generally it is not advised to authenticate two models. Only in really rare cases this is needed. (Think of Uber which has drivers and clients booking the rides).
If you want to have an admin and a normal user, the way to do it is to add a column in the user model called admin
which is a boolean. This way you only have one user model - most of the times the admin can do at leat what the user can do.
If your user is an admin, you just set the admin boolean to true :)
Upvotes: 2