Project provide the end to end solution for authentication. It covers following points:-
- User creation
- Login
- logout
- Reset password / Forget password
Request: POST
api: /api/auth/create
Request: { name: string;
email: string;
password: string; }
Success: Return user success message
Request: POST
api: /api/auth/login
Request: { username: string;
password: string; }
Success: { email: string;
name: string;
role: string;
token: string;
loginTime: number; }
Request: GET
api: /api/auth/logout
Require "authorization" Header with recived token.
Verifies if user exists and sends reset token which can be used to reset password by password serivice
Request: POST
api: /api/reset/verifyUser
Request: { email: string; }
Success: { resetToken: string;
email: string; }
Takes reset token which is send by verifyUser service
Request: POST
api: /api/reset/password
Request: { resetToken: string;
password: string;
confirmPassword: string;
email: string; }
Request: POST
api: /api/auth/verify
Require "authorization" Header with recived token.
Request: GET
api: /
Return client application which can be used to login / create user / change password.
Application configurations can be updated using config.js
1: Port Default port is 8080 but can be updated as required.
2: db_url DB url where authorization collection is present.
3: auth_token_timeout Duration for which auth token send to client side will be valid. Default is 1 day.
4: refresh_token_timeout Duration for which refresh token will be valid which stats a logined user will be valid into application. Default is 2 days.
5: reset_token_timeout Duration for which password reset token is valid. Default 5 min.
The implementaion is based on JWT tokken having concept of refresh tokken and auth tokken to keep user authenticated and reset token in case of password reset.
Server implementation can be verified using Client application which is present in /client
.
Start client locally
npm run client
Start server locally
npm run server
Build client and server
npm run build