mirror of
https://github.com/immich-app/immich.git
synced 2024-11-27 09:21:05 +02:00
fix: parse quota claim as number (#14178)
This commit is contained in:
parent
34fae31fd4
commit
a3712e40bd
@ -53,7 +53,7 @@ const oauthUserWithDefaultQuota = {
|
|||||||
email,
|
email,
|
||||||
name: ' ',
|
name: ' ',
|
||||||
oauthId: sub,
|
oauthId: sub,
|
||||||
quotaSizeInBytes: 1_073_741_824,
|
quotaSizeInBytes: '1073741824',
|
||||||
storageLabel: null,
|
storageLabel: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -567,7 +567,7 @@ describe('AuthService', () => {
|
|||||||
oauthResponse,
|
oauthResponse,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(userMock.create).toHaveBeenCalledWith(oauthUserWithDefaultQuota);
|
expect(userMock.create).toHaveBeenCalledWith({ ...oauthUserWithDefaultQuota, quotaSizeInBytes: 1_073_741_824 });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should ignore an invalid storage quota', async () => {
|
it('should ignore an invalid storage quota', async () => {
|
||||||
@ -581,7 +581,7 @@ describe('AuthService', () => {
|
|||||||
oauthResponse,
|
oauthResponse,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(userMock.create).toHaveBeenCalledWith(oauthUserWithDefaultQuota);
|
expect(userMock.create).toHaveBeenCalledWith({ ...oauthUserWithDefaultQuota, quotaSizeInBytes: 1_073_741_824 });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should ignore a negative quota', async () => {
|
it('should ignore a negative quota', async () => {
|
||||||
@ -595,7 +595,7 @@ describe('AuthService', () => {
|
|||||||
oauthResponse,
|
oauthResponse,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(userMock.create).toHaveBeenCalledWith(oauthUserWithDefaultQuota);
|
expect(userMock.create).toHaveBeenCalledWith({ ...oauthUserWithDefaultQuota, quotaSizeInBytes: 1_073_741_824 });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not set quota for 0 quota', async () => {
|
it('should not set quota for 0 quota', async () => {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { BadRequestException, ForbiddenException, Injectable, UnauthorizedException } from '@nestjs/common';
|
import { BadRequestException, ForbiddenException, Injectable, UnauthorizedException } from '@nestjs/common';
|
||||||
import { isNumber, isString } from 'class-validator';
|
import { isString } from 'class-validator';
|
||||||
import cookieParser from 'cookie';
|
import cookieParser from 'cookie';
|
||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
import { IncomingHttpHeaders } from 'node:http';
|
import { IncomingHttpHeaders } from 'node:http';
|
||||||
@ -226,7 +226,7 @@ export class AuthService extends BaseService {
|
|||||||
const storageQuota = this.getClaim(profile, {
|
const storageQuota = this.getClaim(profile, {
|
||||||
key: storageQuotaClaim,
|
key: storageQuotaClaim,
|
||||||
default: defaultStorageQuota,
|
default: defaultStorageQuota,
|
||||||
isValid: (value: unknown) => isNumber(value) && value >= 0,
|
isValid: (value: unknown) => Number(value) >= 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
const userName = profile.name ?? `${profile.given_name || ''} ${profile.family_name || ''}`;
|
const userName = profile.name ?? `${profile.given_name || ''} ${profile.family_name || ''}`;
|
||||||
|
Loading…
Reference in New Issue
Block a user