Photo by Desola Lanre-Ologun on Unsplash
Creating a login system using jwt
Creating a login system with jwt tokens.
Now I will create a basic login system API, which helps users log in and store the jwt token in a cookie and access routes that require authentication. Just as a side project.
Process of creating it:
- create a session to set is_login session.
- create a jwt update route if he user is login.
- jwt should be stored in a cookie as smaesite="Lax"
- check if the jwt is expired or not. if it is then update the jwt cookie with a new token.
- create a loginout route for logging out the user by deleting the is_login session and setting the jwt_token cookie expiration time to 0.