You've already forked immich
mirror of
https://github.com/immich-app/immich.git
synced 2025-08-09 23:17:29 +02:00
Api logout route (#361)
* Add logout route that deletes http only cookies * Rebuild API
This commit is contained in:
@@ -16,6 +16,8 @@ import { SignUpDto } from './dto/sign-up.dto';
|
||||
import { AdminSignupResponseDto } from './response-dto/admin-signup-response.dto';
|
||||
import { ValidateAccessTokenResponseDto } from './response-dto/validate-asset-token-response.dto,';
|
||||
import { Response } from 'express';
|
||||
import { LogoutResponseDto } from './response-dto/logout-response.dto';
|
||||
|
||||
@ApiTags('Authentication')
|
||||
@Controller('auth')
|
||||
export class AuthController {
|
||||
@@ -51,4 +53,16 @@ export class AuthController {
|
||||
async validateAccessToken(@GetAuthUser() authUser: AuthUserDto): Promise<ValidateAccessTokenResponseDto> {
|
||||
return new ValidateAccessTokenResponseDto(true);
|
||||
}
|
||||
|
||||
@Post('/logout')
|
||||
async logout(@Res() response: Response): Promise<LogoutResponseDto> {
|
||||
response.clearCookie('immich_access_token');
|
||||
response.clearCookie('immich_is_authenticated');
|
||||
|
||||
const status = new LogoutResponseDto(true);
|
||||
|
||||
response.send(status)
|
||||
return status;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,10 @@
|
||||
import { ApiResponseProperty } from '@nestjs/swagger';
|
||||
|
||||
export class LogoutResponseDto {
|
||||
constructor (successful: boolean) {
|
||||
this.successful = successful;
|
||||
}
|
||||
|
||||
@ApiResponseProperty()
|
||||
successful!: boolean;
|
||||
};
|
Reference in New Issue
Block a user