mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
feat(server): Allow activating non-admin user with server license (#11206)
* feat(server): allow server license to activate a user * feat(web): send server+client licenses to user activation when non-admin * chore(server): update test to allow server license to activate user * fix(web): correctly load user to determine where to save license
This commit is contained in:
parent
d180373ec1
commit
ade2901259
3 changed files with 29 additions and 7 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { BadRequestException, Inject, Injectable, NotFoundException } from '@nestjs/common';
|
||||
import { DateTime } from 'luxon';
|
||||
import { getClientLicensePublicKey } from 'src/config';
|
||||
import { getClientLicensePublicKey, getServerLicensePublicKey } from 'src/config';
|
||||
import { SALT_ROUNDS } from 'src/constants';
|
||||
import { StorageCore, StorageFolder } from 'src/cores/storage.core';
|
||||
import { SystemConfigCore } from 'src/cores/system-config.core';
|
||||
|
|
@ -138,16 +138,23 @@ export class UserService {
|
|||
}
|
||||
|
||||
async setLicense(auth: AuthDto, license: LicenseKeyDto): Promise<LicenseResponseDto> {
|
||||
if (!license.licenseKey.startsWith('IMCL-')) {
|
||||
if (!license.licenseKey.startsWith('IMCL-') && !license.licenseKey.startsWith('IMSV-')) {
|
||||
throw new BadRequestException('Invalid license key');
|
||||
}
|
||||
const licenseValid = this.cryptoRepository.verifySha256(
|
||||
|
||||
const clientLicenseValid = this.cryptoRepository.verifySha256(
|
||||
license.licenseKey,
|
||||
license.activationKey,
|
||||
getClientLicensePublicKey(),
|
||||
);
|
||||
|
||||
if (!licenseValid) {
|
||||
const serverLicenseValid = this.cryptoRepository.verifySha256(
|
||||
license.licenseKey,
|
||||
license.activationKey,
|
||||
getServerLicensePublicKey(),
|
||||
);
|
||||
|
||||
if (!clientLicenseValid && !serverLicenseValid) {
|
||||
throw new BadRequestException('Invalid license key');
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue