HackYourFuture-CPH / fp-class18

Interior design webshop
MIT License
1 stars 0 forks source link

Backend: add token authorisation to api calls #263

Open Jul-S opened 2 years ago

Jul-S commented 2 years ago

User story

Who: As a developer What: I want to be able to validates the user that makes api calls Why: so that I can be sure only authenticated user can access user related data

Acceptance criteria

Only api request with a firebase token in the header are allowed

Implementation details.

  1. Create getUserToken method for the Firebase provider
  2. Save user Token in local storage
  3. Add authorisation check middleware that decodes Token to all API calls
  4. Add authorisation with user token in header to all fetch calls in pages
  5. Handle unauthorized errors from API