NG user session

Hi,

I’m creating an API based NG application, and i need to be able to create a session for the authenticated user.
The authentication is done via API call, and i don’t have any users in the database that is linked to the NG application.
I cannot find any way of using the browser session. Please tell me what is the best approac for this.
I need to keep the user logged in even if the user closes the browser and then opens it again.
It’s a 2 factor autentication through API and each login costs money to my customer, so he wants to keep the users logged in for 24 hours (if the user doens’t click the logout button)

Thank you!

Store session token via JWT in local storage of the browser.
At the same time you can store that token in the database.
Both JWT and token in database can have expiry date.

When a user wants to access the solution: check the JWT. If valid you can check if the token exists as record token in DB.
If all is valid: proceed, otherwise reject and let them login using 2FA.

You can also implement Google Authenticator method as 2FA, as that doesn’t need an external service it is free of charge.