Refactored Auth with Sessions #12
|
@ -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({
|
||||
|
|
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue