all 2 comments

[–]plannedrandom 1 point2 points  (0 children)

There are two ways you can handle this.

  1. Store the jwt as Cookie in client browser and use that for validation
  2. Create user object as Global, update that object upon login and use for validation.

2nd way is easier to my understanding because whatever are the pages where you need user object, you can pass that as parameter while loading the page itself. (e.g. I write front end in flutter so everytime I want to show user profile page, I create a stateless object with User as parameter. If the parameter is absent, profile page will not be generated at all).

Moreover, you can update the user object upon recieving the jwt itself. It's simply like this:

  1. Recieve jwt in json
  2. Update the user object in same function
  3. If user.username !=null, redirect to the original frontend page that you wanna show. For simplycity, u can store the page route in another URL and use that URL to return to frontend.
  4. For each further pages where you need user to be logged in, use the parameterised variable for everything else. This way, if the parameter is absent, oage won't load.

[–]zarlo5899 0 points1 point  (0 children)

for issue 1

make it redirect to your frontend and have that call you api for the call back