MyElectricSheep / React-Front-End-Auth-Practice

Exercise to make students practice the front-end auth flow in a React app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

React Front-End Auth Practice

  • This is an exercise I created for the WBS Coding School to make web dev students practice their React + JWT front-end authentication skills.

Front-End Auth React Flow

You can send a POST request to this API endpoint

Send the following JSON along with your request:

{
      "username": "ben"
      "password": "chicken"
}

To get a valid JWT sent back by the API.

Then you can query with a GET request this other endpoint

If the token is valid, you'll get some information about the user sent back. If the token is invalid you'll get a 401 error.

  • Hint: the token will be sent back in the HTTP headers as x-authorization-token
  • Hint2: send your GET request to the API with the token in the headers as well Bearer <your-JWT> to get some data back

About

Exercise to make students practice the front-end auth flow in a React app


Languages

Language:JavaScript 89.3%Language:HTML 10.7%