Iuliia Saprykina
2 min readJun 1, 2020

--

AUTH Part Second

Second part of AUTH — verify user identity in Rails. In previous post we already created a user controller, model and route for create action. Let’s continue with our simple example.

1 step — Create a login route.

Inside the route.rb file write a new route for login action.

2 step — Create a controller Authentication

Run in your terminal: rails g controller Authentication.

3 step — Create a login action

Inside the Authentication_controller.rb write a login action.

4 step — Set gem “JWT”

Inside Gemfile write: gem “jwt”, then run in your terminal: bundle install.

5 step — Check our verification in Postman.

If everything is ok, you will see your new token:

If you change the username in Body, you will see:

If you write a wrong password, you will see:

--

--