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)
@Post('logout')
public async logout(@Req() request: Request): Promise<void> {
this.authService.logout(request.sessionID);
public async logout(@Req() request: Request): Promise<{ success: boolean }> {
return this.authService.logout(request.sessionID);
}
}

View File

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