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 15 additions and 15 deletions
Showing only changes of commit 876f0b42b8 - Show all commits

View File

@ -56,9 +56,9 @@ export class AuthController {
})
@HttpCode(HttpStatus.OK)
@UseGuards(SessionGuard)
@Post('logout')
public async logout(@Req() request: Request): Promise<SuccessDto> {
return this.authService.logout(request.sessionID);
@Post('signout')
public async signout(@Req() request: Request): Promise<SuccessDto> {
return this.authService.signout(request.sessionID);
}
@ApiCreatedResponse({

View File

@ -110,6 +110,18 @@ export class AuthService {
}
}
public async signout(sessionId: string): Promise<{ success: boolean }> {
try {
this.sessionService.deleteSessionBySessionId(sessionId);
return { success: true };
} catch (error) {
throw new HttpException(
'Fehler beim Logout',
HttpStatus.INTERNAL_SERVER_ERROR
);
}
}
public async checkAuthStatus(
sessionId: string,
userAgend: string
@ -145,16 +157,4 @@ export class AuthService {
return responseData;
}
public async logout(sessionId: string): Promise<{ success: boolean }> {
try {
this.sessionService.deleteSessionBySessionId(sessionId);
return { success: true };
} catch (error) {
throw new HttpException(
'Fehler beim Logout',
HttpStatus.INTERNAL_SERVER_ERROR
);
}
}
}