fix(web): OAuth quota size (#18526)

fix(server): oauth quota size
This commit is contained in:
Daimolean
2025-06-13 22:57:29 +08:00
committed by GitHub
parent e2dfbd66c3
commit 004c2f2496
12 changed files with 24 additions and 16 deletions

View File

@@ -89,7 +89,7 @@ export interface SystemConfig {
buttonText: string;
clientId: string;
clientSecret: string;
defaultStorageQuota: number;
defaultStorageQuota: number | null;
enabled: boolean;
issuerUrl: string;
mobileOverrideEnabled: boolean;
@@ -253,7 +253,7 @@ export const defaults = Object.freeze<SystemConfig>({
buttonText: 'Login with OAuth',
clientId: '',
clientSecret: '',
defaultStorageQuota: 0,
defaultStorageQuota: null,
enabled: false,
issuerUrl: '',
mobileOverrideEnabled: false,

View File

@@ -360,7 +360,9 @@ class SystemConfigOAuthDto {
@IsNumber()
@Min(0)
defaultStorageQuota!: number;
@Optional({ nullable: true })
@ApiProperty({ type: 'integer', format: 'int64' })
defaultStorageQuota!: number | null;
@ValidateBoolean()
enabled!: boolean;

View File

@@ -704,7 +704,7 @@ describe(AuthService.name, () => {
expect(mocks.user.create).toHaveBeenCalledWith(expect.objectContaining({ quotaSizeInBytes: 1_073_741_824 }));
});
it('should not set quota for 0 quota', async () => {
it('should set quota for 0 quota', async () => {
const user = factory.userAdmin({ oauthId: 'oauth-id' });
mocks.systemMetadata.get.mockResolvedValue(systemConfigStub.oauthWithStorageQuota);
@@ -726,7 +726,7 @@ describe(AuthService.name, () => {
email: user.email,
name: ' ',
oauthId: user.oauthId,
quotaSizeInBytes: null,
quotaSizeInBytes: 0,
storageLabel: null,
});
});

View File

@@ -300,7 +300,7 @@ export class AuthService extends BaseService {
name: userName,
email: profile.email,
oauthId: profile.sub,
quotaSizeInBytes: storageQuota * HumanReadableSize.GiB || null,
quotaSizeInBytes: storageQuota === null ? null : storageQuota * HumanReadableSize.GiB,
storageLabel: storageLabel || null,
});
}

View File

@@ -112,7 +112,7 @@ const updatedConfig = Object.freeze<SystemConfig>({
buttonText: 'Login with OAuth',
clientId: '',
clientSecret: '',
defaultStorageQuota: 0,
defaultStorageQuota: null,
enabled: false,
issuerUrl: '',
mobileOverrideEnabled: false,