mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
refactor(web): shared link key auth (#3855)
This commit is contained in:
parent
10c2bda3a9
commit
9bbef4a97b
21 changed files with 115 additions and 108 deletions
|
|
@ -39,6 +39,11 @@ export class ImmichApi {
|
|||
public userApi: UserApi;
|
||||
|
||||
private config: Configuration;
|
||||
private key?: string;
|
||||
|
||||
get isSharedLink() {
|
||||
return !!this.key;
|
||||
}
|
||||
|
||||
constructor(params: ConfigurationParameters) {
|
||||
this.config = new Configuration(params);
|
||||
|
|
@ -73,6 +78,14 @@ export class ImmichApi {
|
|||
return (this.config.basePath || BASE_PATH) + toPathString(url);
|
||||
}
|
||||
|
||||
public setKey(key: string) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public getKey(): string | undefined {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public setAccessToken(accessToken: string) {
|
||||
this.config.accessToken = accessToken;
|
||||
}
|
||||
|
|
@ -85,14 +98,14 @@ export class ImmichApi {
|
|||
this.config.basePath = baseUrl;
|
||||
}
|
||||
|
||||
public getAssetFileUrl(...[assetId, isThumb, isWeb, key]: ApiParams<typeof AssetApiFp, 'serveFile'>) {
|
||||
public getAssetFileUrl(...[assetId, isThumb, isWeb]: ApiParams<typeof AssetApiFp, 'serveFile'>) {
|
||||
const path = `/asset/file/${assetId}`;
|
||||
return this.createUrl(path, { isThumb, isWeb, key });
|
||||
return this.createUrl(path, { isThumb, isWeb, key: this.getKey() });
|
||||
}
|
||||
|
||||
public getAssetThumbnailUrl(...[assetId, format, key]: ApiParams<typeof AssetApiFp, 'getAssetThumbnail'>) {
|
||||
public getAssetThumbnailUrl(...[assetId, format]: ApiParams<typeof AssetApiFp, 'getAssetThumbnail'>) {
|
||||
const path = `/asset/thumbnail/${assetId}`;
|
||||
return this.createUrl(path, { format, key });
|
||||
return this.createUrl(path, { format, key: this.getKey() });
|
||||
}
|
||||
|
||||
public getProfileImageUrl(...[userId]: ApiParams<typeof UserApiFp, 'getProfileImage'>) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue