user can signin using email/username and password.
add form side validations
redirect to home page after successful signin, main page will be user role specific
NOTE:
only buyer & seller can use this form.
can anybody help me how i can create this?
CodePudding user response:
Have you checked this gem called devise? It's very practical and the documentation is all there. It also helps you with the three points you mentioned.
You can learn more about devise here https://github.com/heartcombo/devise
CodePudding user response:
I will quickly expand on @Aulia's suggestion:
While you are of course free to code your own signup/login functionality its probably best to use Devise since its a well maintained gem that does everything you could think of regarding authentication. Note that eventually you will want only certain users to perform certain actions, that will fall under authorization and for that you might want Pundit.
As for devise, once you have added the gem (you can follow the steps on the github page) I will caution you to not make separate devise models for buyers / sellers unless those two table are very different.
I assume you have a User model and that there is a seller boolean attached, so you might want to do this:
rails generate devise User
Devise will create specific routes and views for your app, so its plug and play.
One last warning, if you choose devise, but want additional fields on signup (maybe you need to select to be a seller on signup?) you will need to sanitize those additional fields, so keep that in mind!
