mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
Api logout route (#361)
* Add logout route that deletes http only cookies * Rebuild API
This commit is contained in:
parent
be3e3e5d7e
commit
bef1e2e3db
13 changed files with 334 additions and 1 deletions
|
|
@ -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;
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue