feat(server): remove phone number from authentication process

This commit is contained in:
a.bouhuolia
2023-04-05 04:18:12 +02:00
parent da20b7c837
commit 961ff74880
14 changed files with 496 additions and 414 deletions

View File

@@ -0,0 +1,22 @@
import JWT from 'jsonwebtoken';
import { ISystemUser } from '@/interfaces';
import config from '@/config';
/**
* Generates JWT token for the given user.
* @param {ISystemUser} user
* @return {string} token
*/
export const generateToken = (user: ISystemUser): string => {
const today = new Date();
const exp = new Date(today);
exp.setDate(today.getDate() + 60);
return JWT.sign(
{
id: user.id, // We are gonna use this in the middleware 'isAuth'
exp: exp.getTime() / 1000,
},
config.jwtSecret
);
};