Skip to content

Commit 3b88e3a

Browse files
author
wuzihao051119
committed
fix(server): OAuth quota size
1 parent 2d7377a commit 3b88e3a

File tree

11 files changed

+28
-20
lines changed

11 files changed

+28
-20
lines changed

i18n/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
"oauth_storage_quota_claim": "Storage quota claim",
208208
"oauth_storage_quota_claim_description": "Automatically set the user's storage quota to the value of this claim.",
209209
"oauth_storage_quota_default": "Default storage quota (GiB)",
210-
"oauth_storage_quota_default_description": "Quota in GiB to be used when no claim is provided (Enter 0 for unlimited quota).",
210+
"oauth_storage_quota_default_description": "Quota in GiB to be used when no claim is provided.",
211211
"oauth_timeout": "Request Timeout",
212212
"oauth_timeout_description": "Timeout for requests in milliseconds",
213213
"offline_paths": "Offline Paths",

mobile/openapi/lib/model/system_config_o_auth_dto.dart

Lines changed: 14 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

open-api/immich-openapi-specs.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13685,8 +13685,9 @@
1368513685
"type": "string"
1368613686
},
1368713687
"defaultStorageQuota": {
13688+
"format": "int64",
1368813689
"minimum": 0,
13689-
"type": "number"
13690+
"type": "integer"
1369013691
},
1369113692
"enabled": {
1369213693
"type": "boolean"
@@ -13734,7 +13735,6 @@
1373413735
"buttonText",
1373513736
"clientId",
1373613737
"clientSecret",
13737-
"defaultStorageQuota",
1373813738
"enabled",
1373913739
"issuerUrl",
1374013740
"mobileOverrideEnabled",

open-api/typescript-sdk/src/fetch-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,7 @@ export type SystemConfigOAuthDto = {
13161316
buttonText: string;
13171317
clientId: string;
13181318
clientSecret: string;
1319-
defaultStorageQuota: number;
1319+
defaultStorageQuota?: number;
13201320
enabled: boolean;
13211321
issuerUrl: string;
13221322
mobileOverrideEnabled: boolean;

server/src/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export interface SystemConfig {
8989
buttonText: string;
9090
clientId: string;
9191
clientSecret: string;
92-
defaultStorageQuota: number;
92+
defaultStorageQuota?: number;
9393
enabled: boolean;
9494
issuerUrl: string;
9595
mobileOverrideEnabled: boolean;
@@ -253,7 +253,7 @@ export const defaults = Object.freeze<SystemConfig>({
253253
buttonText: 'Login with OAuth',
254254
clientId: '',
255255
clientSecret: '',
256-
defaultStorageQuota: 0,
256+
defaultStorageQuota: undefined,
257257
enabled: false,
258258
issuerUrl: '',
259259
mobileOverrideEnabled: false,

server/src/dtos/system-config.dto.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,9 @@ class SystemConfigOAuthDto {
360360

361361
@IsNumber()
362362
@Min(0)
363-
defaultStorageQuota!: number;
363+
@Optional()
364+
@ApiProperty({ type: 'integer', format: 'int64' })
365+
defaultStorageQuota?: number;
364366

365367
@ValidateBoolean()
366368
enabled!: boolean;

server/src/services/auth.service.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ describe(AuthService.name, () => {
702702
expect(mocks.user.create).toHaveBeenCalledWith(expect.objectContaining({ quotaSizeInBytes: 1_073_741_824 }));
703703
});
704704

705-
it('should not set quota for 0 quota', async () => {
705+
it('should set quota for 0 quota', async () => {
706706
const user = factory.userAdmin({ oauthId: 'oauth-id' });
707707

708708
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.oauthWithStorageQuota);
@@ -724,7 +724,7 @@ describe(AuthService.name, () => {
724724
email: user.email,
725725
name: ' ',
726726
oauthId: user.oauthId,
727-
quotaSizeInBytes: null,
727+
quotaSizeInBytes: 0,
728728
storageLabel: null,
729729
});
730730
});

server/src/services/auth.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ export class AuthService extends BaseService {
300300
name: userName,
301301
email: profile.email,
302302
oauthId: profile.sub,
303-
quotaSizeInBytes: storageQuota * HumanReadableSize.GiB || null,
303+
quotaSizeInBytes: storageQuota === undefined ? null : storageQuota * HumanReadableSize.GiB,
304304
storageLabel: storageLabel || null,
305305
});
306306
}

server/src/utils/misc.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ export const getKeysDeep = (target: unknown, path: string[] = []) => {
5959
const properties: string[] = [];
6060
for (const key of Object.keys(obj as object)) {
6161
const value = obj[key as keyof object];
62-
if (value === undefined) {
63-
continue;
64-
}
6562

6663
if (_.isObject(value) && !_.isArray(value) && !_.isDate(value)) {
6764
properties.push(...getKeysDeep(value, [...path, key]));

web/src/lib/components/admin-page/settings/auth/auth-settings.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@
182182
label={$t('admin.oauth_storage_quota_default').toUpperCase()}
183183
description={$t('admin.oauth_storage_quota_default_description')}
184184
bind:value={config.oauth.defaultStorageQuota}
185-
required={true}
185+
required={false}
186186
disabled={disabled || !config.oauth.enabled}
187187
isEdited={!(config.oauth.defaultStorageQuota == savedConfig.oauth.defaultStorageQuota)}
188188
/>

0 commit comments

Comments
 (0)