mirror of
https://github.com/immich-app/immich.git
synced 2024-12-25 10:43:13 +02:00
Api logout route (#361)
* Add logout route that deletes http only cookies * Rebuild API
This commit is contained in:
parent
be3e3e5d7e
commit
bef1e2e3db
@ -29,6 +29,7 @@ doc/DeviceTypeEnum.md
|
|||||||
doc/ExifResponseDto.md
|
doc/ExifResponseDto.md
|
||||||
doc/LoginCredentialDto.md
|
doc/LoginCredentialDto.md
|
||||||
doc/LoginResponseDto.md
|
doc/LoginResponseDto.md
|
||||||
|
doc/LogoutResponseDto.md
|
||||||
doc/RemoveAssetsDto.md
|
doc/RemoveAssetsDto.md
|
||||||
doc/SearchAssetDto.md
|
doc/SearchAssetDto.md
|
||||||
doc/ServerInfoApi.md
|
doc/ServerInfoApi.md
|
||||||
@ -84,6 +85,7 @@ lib/model/device_type_enum.dart
|
|||||||
lib/model/exif_response_dto.dart
|
lib/model/exif_response_dto.dart
|
||||||
lib/model/login_credential_dto.dart
|
lib/model/login_credential_dto.dart
|
||||||
lib/model/login_response_dto.dart
|
lib/model/login_response_dto.dart
|
||||||
|
lib/model/logout_response_dto.dart
|
||||||
lib/model/remove_assets_dto.dart
|
lib/model/remove_assets_dto.dart
|
||||||
lib/model/search_asset_dto.dart
|
lib/model/search_asset_dto.dart
|
||||||
lib/model/server_info_response_dto.dart
|
lib/model/server_info_response_dto.dart
|
||||||
@ -99,3 +101,4 @@ lib/model/user_count_response_dto.dart
|
|||||||
lib/model/user_response_dto.dart
|
lib/model/user_response_dto.dart
|
||||||
lib/model/validate_access_token_response_dto.dart
|
lib/model/validate_access_token_response_dto.dart
|
||||||
pubspec.yaml
|
pubspec.yaml
|
||||||
|
test/logout_response_dto_test.dart
|
||||||
|
Binary file not shown.
Binary file not shown.
BIN
mobile/openapi/doc/LogoutResponseDto.md
Normal file
BIN
mobile/openapi/doc/LogoutResponseDto.md
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
mobile/openapi/lib/model/logout_response_dto.dart
Normal file
BIN
mobile/openapi/lib/model/logout_response_dto.dart
Normal file
Binary file not shown.
BIN
mobile/openapi/test/logout_response_dto_test.dart
Normal file
BIN
mobile/openapi/test/logout_response_dto_test.dart
Normal file
Binary file not shown.
@ -16,6 +16,8 @@ import { SignUpDto } from './dto/sign-up.dto';
|
|||||||
import { AdminSignupResponseDto } from './response-dto/admin-signup-response.dto';
|
import { AdminSignupResponseDto } from './response-dto/admin-signup-response.dto';
|
||||||
import { ValidateAccessTokenResponseDto } from './response-dto/validate-asset-token-response.dto,';
|
import { ValidateAccessTokenResponseDto } from './response-dto/validate-asset-token-response.dto,';
|
||||||
import { Response } from 'express';
|
import { Response } from 'express';
|
||||||
|
import { LogoutResponseDto } from './response-dto/logout-response.dto';
|
||||||
|
|
||||||
@ApiTags('Authentication')
|
@ApiTags('Authentication')
|
||||||
@Controller('auth')
|
@Controller('auth')
|
||||||
export class AuthController {
|
export class AuthController {
|
||||||
@ -51,4 +53,16 @@ export class AuthController {
|
|||||||
async validateAccessToken(@GetAuthUser() authUser: AuthUserDto): Promise<ValidateAccessTokenResponseDto> {
|
async validateAccessToken(@GetAuthUser() authUser: AuthUserDto): Promise<ValidateAccessTokenResponseDto> {
|
||||||
return new ValidateAccessTokenResponseDto(true);
|
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
@ -782,6 +782,19 @@ export interface LoginResponseDto {
|
|||||||
*/
|
*/
|
||||||
'shouldChangePassword': boolean;
|
'shouldChangePassword': boolean;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @interface LogoutResponseDto
|
||||||
|
*/
|
||||||
|
export interface LogoutResponseDto {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {boolean}
|
||||||
|
* @memberof LogoutResponseDto
|
||||||
|
*/
|
||||||
|
'successful': boolean;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @export
|
* @export
|
||||||
@ -2885,6 +2898,35 @@ export const AuthenticationApiAxiosParamCreator = function (configuration?: Conf
|
|||||||
options: localVarRequestOptions,
|
options: localVarRequestOptions,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
logout: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||||
|
const localVarPath = `/auth/logout`;
|
||||||
|
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||||
|
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
||||||
|
let baseOptions;
|
||||||
|
if (configuration) {
|
||||||
|
baseOptions = configuration.baseOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
|
||||||
|
const localVarHeaderParameter = {} as any;
|
||||||
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
||||||
|
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||||
|
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||||
|
|
||||||
|
return {
|
||||||
|
url: toPathString(localVarUrlObj),
|
||||||
|
options: localVarRequestOptions,
|
||||||
|
};
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
@ -2948,6 +2990,15 @@ export const AuthenticationApiFp = function(configuration?: Configuration) {
|
|||||||
const localVarAxiosArgs = await localVarAxiosParamCreator.login(loginCredentialDto, options);
|
const localVarAxiosArgs = await localVarAxiosParamCreator.login(loginCredentialDto, options);
|
||||||
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
async logout(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<LogoutResponseDto>> {
|
||||||
|
const localVarAxiosArgs = await localVarAxiosParamCreator.logout(options);
|
||||||
|
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
@ -2985,6 +3036,14 @@ export const AuthenticationApiFactory = function (configuration?: Configuration,
|
|||||||
login(loginCredentialDto: LoginCredentialDto, options?: any): AxiosPromise<LoginResponseDto> {
|
login(loginCredentialDto: LoginCredentialDto, options?: any): AxiosPromise<LoginResponseDto> {
|
||||||
return localVarFp.login(loginCredentialDto, options).then((request) => request(axios, basePath));
|
return localVarFp.login(loginCredentialDto, options).then((request) => request(axios, basePath));
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
logout(options?: any): AxiosPromise<LogoutResponseDto> {
|
||||||
|
return localVarFp.logout(options).then((request) => request(axios, basePath));
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
@ -3025,6 +3084,16 @@ export class AuthenticationApi extends BaseAPI {
|
|||||||
return AuthenticationApiFp(this.configuration).login(loginCredentialDto, options).then((request) => request(this.axios, this.basePath));
|
return AuthenticationApiFp(this.configuration).login(loginCredentialDto, options).then((request) => request(this.axios, this.basePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
* @memberof AuthenticationApi
|
||||||
|
*/
|
||||||
|
public logout(options?: AxiosRequestConfig) {
|
||||||
|
return AuthenticationApiFp(this.configuration).logout(options).then((request) => request(this.axios, this.basePath));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
|
Loading…
Reference in New Issue
Block a user