Compare commits

...

2 Commits

Author SHA1 Message Date
Pau Costa Ferrer 46dd4ccb91 Merge remote-tracking branch 'origin/main'
# Conflicts:
#	server/src/controller/authController.ts
2024-02-02 23:27:18 +01:00
Pau Costa Ferrer 4d39f39c38 Added auth features
Signed-off-by: Pau Costa <mico@micodev.es>
2024-02-02 23:22:36 +01:00
1 changed files with 9 additions and 0 deletions

View File

@ -79,6 +79,15 @@ export class AuthController {
this.sendToken(user, res, {long: longExpiration}) this.sendToken(user, res, {long: longExpiration})
}) })
public handleLogout = catchAsync(async (req: AppRequest, res, next) => {
// Set the jwt cookie to a dummy value and set the expiration to a date in the past
res.cookie('jwt', 'loggedout', {
expires: new Date(Date.now() - 10000),
httpOnly: true
})
res.status(200).json({status: 'success'})
})
public protect = catchAsync(async (req: AppRequest, res, next) => { public protect = catchAsync(async (req: AppRequest, res, next) => {
let token: string | undefined; let token: string | undefined;