feat(core): Logout should invalidate the auth token (no-changelog) (#10335)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2024-08-22 09:33:06 +02:00
committed by GitHub
parent b805e8ddb8
commit 9fe6a71690
16 changed files with 158 additions and 23 deletions

View File

@@ -1,9 +1,9 @@
import validator from 'validator';
import { Response } from 'express';
import { AuthService } from '@/auth/auth.service';
import { Get, Post, RestController } from '@/decorators';
import { RESPONSE_ERROR_MESSAGES } from '@/constants';
import { Request, Response } from 'express';
import type { User } from '@db/entities/User';
import { AuthenticatedRequest, LoginRequest, UserRequest } from '@/requests';
import type { PublicUser } from '@/Interfaces';
@@ -185,7 +185,8 @@ export class AuthController {
/** Log out a user */
@Post('/logout')
logout(_: Request, res: Response) {
async logout(req: AuthenticatedRequest, res: Response) {
await this.authService.invalidateToken(req);
this.authService.clearCookie(res);
return { loggedOut: true };
}