| Start |
|---|
| Authentication using Devise Add gem to the Gemfile:
Then run the Use command Set up the default URL options for the Devise mailer in each environment In development environment add this line: to your similarly in production this edit Then create a model using: Finally, run: Custom viewsIf you need to configure your views, you can use the If you have more than one Devise model in your application (for example User and Admin), you will notice that Devise uses the same views for all models. Devise offers an easy way to customize views. Set You can also use the generator to create scoped views: If you would like to generate only a few sets of views, such as the ones for the registerable and confirmable module use the -v flag: |
| Devise Controller Filters & Helpers To set up a controller with user authentication using devise, add this before_action: (assuming your devise model is 'User'):
To verify if a user is signed in, use the following helper:
For the current signed-in user, use this helper:
You can access the session for this scope:
|
| Omniauth First choose your auth strategy and add it to your You can add this to your rails middleware like so: By default, OmniAuth will add By default, if there is a failure, omniauth will redirect to |
has_secure_password Create User Model
Add has_secure_password module to User modelVerify password with authenticate method |
| has_secure_token Create User Model Now when you create a new user a token and auth_token are automatically generated You can update the tokens using RemarksAt the time of generating devise configs using If you already have a Use this helper method |
Read Article
https://develop.horje.com/learn/1434/reference