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
|
|
@ -3,11 +3,14 @@ import type { ImmichLicense } from '$lib/constants';
|
|||
import { serverConfig } from '$lib/stores/server-config.store';
|
||||
import { setServerLicense, setUserLicense, type LicenseResponseDto } from '@immich/sdk';
|
||||
import { get } from 'svelte/store';
|
||||
import { loadUser } from './auth';
|
||||
|
||||
export const activateLicense = async (licenseKey: string, activationKey: string): Promise<LicenseResponseDto> => {
|
||||
const isServerKey = licenseKey.search('IMSV') !== -1;
|
||||
// Send server key to user activation if user is not admin
|
||||
const user = await loadUser();
|
||||
const isServerActivation = user?.isAdmin && licenseKey.search('IMSV') !== -1;
|
||||
const licenseKeyDto = { licenseKey, activationKey };
|
||||
return isServerKey ? setServerLicense({ licenseKeyDto }) : setUserLicense({ licenseKeyDto });
|
||||
return isServerActivation ? setServerLicense({ licenseKeyDto }) : setUserLicense({ licenseKeyDto });
|
||||
};
|
||||
|
||||
export const getActivationKey = async (licenseKey: string): Promise<string> => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue