From fcd147bca4b70b52e895ec5130f86b59330433c0 Mon Sep 17 00:00:00 2001 From: Igor Propisnov Date: Wed, 5 Jun 2024 15:06:19 +0200 Subject: [PATCH] added logout --- .../src/modules/auth-module/controller/auth.controller.ts | 8 ++++++-- backend/src/modules/auth-module/services/auth.service.ts | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/backend/src/modules/auth-module/controller/auth.controller.ts b/backend/src/modules/auth-module/controller/auth.controller.ts index ce279fe..e5df2c8 100644 --- a/backend/src/modules/auth-module/controller/auth.controller.ts +++ b/backend/src/modules/auth-module/controller/auth.controller.ts @@ -48,9 +48,13 @@ export class AuthController { ); } + @ApiCreatedResponse({ + description: 'User signed out', + }) + @HttpCode(HttpStatus.OK) @UseGuards(SessionGuard) @Post('logout') - public async logout(@Req() request: Request): Promise { - this.authService.logout(request.sessionID); + public async logout(@Req() request: Request): Promise<{ success: boolean }> { + return this.authService.logout(request.sessionID); } } diff --git a/backend/src/modules/auth-module/services/auth.service.ts b/backend/src/modules/auth-module/services/auth.service.ts index e18dbcd..6677a12 100644 --- a/backend/src/modules/auth-module/services/auth.service.ts +++ b/backend/src/modules/auth-module/services/auth.service.ts @@ -119,9 +119,10 @@ export class AuthService { return responseData; } - public async logout(sessionId: string): Promise { + public async logout(sessionId: string): Promise<{ success: boolean }> { try { this.sessionService.deleteSessionBySessionId(sessionId); + return { success: true }; } catch (error) { throw new HttpException( 'Fehler beim Logout',