Refactored Auth with Sessions #12

Merged
igorpropisnov merged 9 commits from feature/refactor-auth into main 2024-06-06 12:58:52 +02:00
2 changed files with 8 additions and 3 deletions
Showing only changes of commit fcd147bca4 - Show all commits

View File

@ -48,9 +48,13 @@ export class AuthController {
); );
} }
@ApiCreatedResponse({
description: 'User signed out',
})
@HttpCode(HttpStatus.OK)
@UseGuards(SessionGuard) @UseGuards(SessionGuard)
@Post('logout') @Post('logout')
public async logout(@Req() request: Request): Promise<void> { public async logout(@Req() request: Request): Promise<{ success: boolean }> {
this.authService.logout(request.sessionID); return this.authService.logout(request.sessionID);
} }
} }

View File

@ -119,9 +119,10 @@ export class AuthService {
return responseData; return responseData;
} }
public async logout(sessionId: string): Promise<void> { public async logout(sessionId: string): Promise<{ success: boolean }> {
try { try {
this.sessionService.deleteSessionBySessionId(sessionId); this.sessionService.deleteSessionBySessionId(sessionId);
return { success: true };
} catch (error) { } catch (error) {
throw new HttpException( throw new HttpException(
'Fehler beim Logout', 'Fehler beim Logout',