Skip to content

hggeorgiev/rails-jwt-auth-tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rails Authentication with JSON Web Token

This is part of a tutorial article about authentication with JWT tokens in rails You can view the tutorial here

Setup

rvm install 2.3.0
rvm use 2.3.0
  • Install Gems
bundle install
  • Migrate into database
rails db:migrate
  • Run the server
rails s
  • Open a new Terminal.app tab and create a new user using Rails Console
rails console

User.create(:email => 'example@mail.com', :password => '123123123', :password_confirmation => '123123123')
  • Open another Terminal.app tab and use cURL to perform a JWT HTTP POST request to back-end
curl -H "Content-Type: application/json" -X POST -d '{"email":"example@mail.com","password":"123123123"}' http://localhost:3000/authenticate