High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
fix(server): Allow passwordless users when oauth enabled (#13517)
jedi04bb694aeeeba3
diff --git a/server/src/dtos/user.dto.ts b/server/src/dtos/user.dto.tsindex 36f0b6386f..593a7934bc 100644--- a/server/src/dtos/user.dto.ts+++ b/server/src/dtos/user.dto.ts@@ -62,7 +62,6 @@ export class UserAdminCreateDto {@Transform(toEmail)email!: string;- @IsNotEmpty()@IsString()password!: string;diff --git a/server/src/services/user-admin.service.ts b/server/src/services/user-admin.service.tsindex 94608a24ac..84a5b5842d 100644--- a/server/src/services/user-admin.service.ts+++ b/server/src/services/user-admin.service.ts@@ -26,6 +26,10 @@ export class UserAdminService extends BaseService {async create(dto: UserAdminCreateDto): Promise<UserAdminResponseDto> {const { notify, ...rest } = dto;+ const config = await this.getConfig({ withCache: false });+ if (!config.oauth.enabled && !rest.password) {+ throw new BadRequestException('password is required');+ }const user = await createUser({ userRepo: this.userRepository, cryptoRepo: this.cryptoRepository }, rest);await this.eventRepository.emit('user.signup', {diff --git a/web/src/lib/components/forms/create-user-form.svelte b/web/src/lib/components/forms/create-user-form.svelteindex 9c4b83002b..0687912542 100644--- a/web/src/lib/components/forms/create-user-form.svelte+++ b/web/src/lib/components/forms/create-user-form.svelte@@ -13,6 +13,7 @@export let onClose: () => void;export let onSubmit: () => void;export let onCancel: () => void;+ export let oauthEnabled = false;let error: string;let success: string;@@ -90,12 +91,17 @@<div class="my-4 flex flex-col gap-2"><label class="immich-form-label" for="password">{$t('password')}</label>- <PasswordField id="password" bind:password autocomplete="new-password" />+ <PasswordField id="password" bind:password autocomplete="new-password" required={!oauthEnabled} /></div><div class="my-4 flex flex-col gap-2"><label class="immich-form-label" for="confirmPassword">{$t('confirm_password')}</label>- <PasswordField id="confirmPassword" bind:password={confirmPassword} autocomplete="new-password" />+ <PasswordField+ id="confirmPassword"+ bind:password={confirmPassword}+ autocomplete="new-password"+ required={!oauthEnabled}+ /></div><div class="my-4 flex place-items-center justify-between gap-2">diff --git a/web/src/routes/admin/user-management/+page.svelte b/web/src/routes/admin/user-management/+page.svelteindex 2313b17cb1..80c0169176 100644--- a/web/src/routes/admin/user-management/+page.svelte+++ b/web/src/routes/admin/user-management/+page.svelte@@ -15,7 +15,7 @@notificationController,} from '$lib/components/shared-components/notification/notification';import { locale } from '$lib/stores/preferences.store';- import { serverConfig } from '$lib/stores/server-config.store';+ import { serverConfig, featureFlags } from '$lib/stores/server-config.store';import { user } from '$lib/stores/user.store';import { websocketEvents } from '$lib/stores/websocket';import { copyToClipboard } from '$lib/utils';@@ -113,6 +113,7 @@onSubmit={onUserCreated}onCancel={() => (shouldShowCreateUserForm = false)}onClose={() => (shouldShowCreateUserForm = false)}+ oauthEnabled={$featureFlags.oauth}/>{/if}