Skip to content

Latest commit

 

History

History

logging-in__jwt

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

logging-in__jwt

Example of logging in using JWT

  • Test login UI form
  • Use cy.request() once to get user object and JWT
  • Before each test set the JWT and the user object in localStorage before visiting the page
  • The opened page instantly has the user logged in

Server

Copied from https://jasonwatmore.com/post/2018/08/06/nodejs-jwt-authentication-tutorial-with-example-api

npm run start:server

Runs the API at port 4000

Front-end

Vue application copied from https://jasonwatmore.com/post/2018/07/06/vue-vuex-jwt-authentication-tutorial-example

npm run start:app

Runs the web application at port 8081

The front-end SPA logs in and stores the JWT and user information in the localStorage item named user

JWT token

All Ajax requests to the protected resources need to have Authorization header with the Bearer <token> value.

Authenticated Ajax call

Tests