diff --git a/server/src/dtos/user.dto.ts b/server/src/dtos/user.dto.ts index 36f0b6386f76d..593a7934bccc1 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.ts index 94608a24ac035..84a5b5842d9b9 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 { 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.svelte index 9c4b83002b77a..0687912542067 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 @@
- +
- +
diff --git a/web/src/routes/admin/user-management/+page.svelte b/web/src/routes/admin/user-management/+page.svelte index 2313b17cb1ea1..80c0169176107 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}