diff --git a/src/controllers/users/auth.ts b/src/controllers/users/auth.ts index dbea51d..418cdb0 100644 --- a/src/controllers/users/auth.ts +++ b/src/controllers/users/auth.ts @@ -11,7 +11,7 @@ async function userAuthController(req: Request, res: Response): Promise { badRequest(res, result.message) } else { res - .cookie('token', result.token, { + .cookie('knedita_token', result.token, { httpOnly: true, secure: process.env.NODE_ENV === 'production', }) diff --git a/src/controllers/users/logout.ts b/src/controllers/users/logout.ts index 38e9735..d63849a 100644 --- a/src/controllers/users/logout.ts +++ b/src/controllers/users/logout.ts @@ -6,7 +6,7 @@ async function userLogoutController( ): Promise { // @ts-expect-error clearCookie interface does not exists in Response. return res - .clearCookie('token') + .clearCookie('knedita_token') .status(200) .json({ message: 'Successfully logged out' }) } diff --git a/src/middlewares/authenticated.ts b/src/middlewares/authenticated.ts index c7ec6ce..ef90e8a 100644 --- a/src/middlewares/authenticated.ts +++ b/src/middlewares/authenticated.ts @@ -10,7 +10,7 @@ async function authenticated( next: NextFunction, ): Promise { try { - const token = req.cookies.token + const token = req.cookies.knedita_token if (token === undefined) { unauthorized(res, 'Missing token')