mirror of
https://github.com/immich-app/immich.git
synced 2025-01-07 00:50:23 -05:00
fix(server): Allow passwordless users when oauth enabled (#13517)
* fix(server): Allow passwordless users when oauth enabled * fix(web): Use features flags for checking oauth
This commit is contained in:
parent
3f663106e8
commit
bb694aeeeb
4 changed files with 14 additions and 4 deletions
|
@ -62,7 +62,6 @@ export class UserAdminCreateDto {
|
||||||
@Transform(toEmail)
|
@Transform(toEmail)
|
||||||
email!: string;
|
email!: string;
|
||||||
|
|
||||||
@IsNotEmpty()
|
|
||||||
@IsString()
|
@IsString()
|
||||||
password!: string;
|
password!: string;
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,10 @@ export class UserAdminService extends BaseService {
|
||||||
|
|
||||||
async create(dto: UserAdminCreateDto): Promise<UserAdminResponseDto> {
|
async create(dto: UserAdminCreateDto): Promise<UserAdminResponseDto> {
|
||||||
const { notify, ...rest } = dto;
|
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);
|
const user = await createUser({ userRepo: this.userRepository, cryptoRepo: this.cryptoRepository }, rest);
|
||||||
|
|
||||||
await this.eventRepository.emit('user.signup', {
|
await this.eventRepository.emit('user.signup', {
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
export let onClose: () => void;
|
export let onClose: () => void;
|
||||||
export let onSubmit: () => void;
|
export let onSubmit: () => void;
|
||||||
export let onCancel: () => void;
|
export let onCancel: () => void;
|
||||||
|
export let oauthEnabled = false;
|
||||||
|
|
||||||
let error: string;
|
let error: string;
|
||||||
let success: string;
|
let success: string;
|
||||||
|
@ -90,12 +91,17 @@
|
||||||
|
|
||||||
<div class="my-4 flex flex-col gap-2">
|
<div class="my-4 flex flex-col gap-2">
|
||||||
<label class="immich-form-label" for="password">{$t('password')}</label>
|
<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>
|
||||||
|
|
||||||
<div class="my-4 flex flex-col gap-2">
|
<div class="my-4 flex flex-col gap-2">
|
||||||
<label class="immich-form-label" for="confirmPassword">{$t('confirm_password')}</label>
|
<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>
|
||||||
|
|
||||||
<div class="my-4 flex place-items-center justify-between gap-2">
|
<div class="my-4 flex place-items-center justify-between gap-2">
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
notificationController,
|
notificationController,
|
||||||
} from '$lib/components/shared-components/notification/notification';
|
} from '$lib/components/shared-components/notification/notification';
|
||||||
import { locale } from '$lib/stores/preferences.store';
|
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 { user } from '$lib/stores/user.store';
|
||||||
import { websocketEvents } from '$lib/stores/websocket';
|
import { websocketEvents } from '$lib/stores/websocket';
|
||||||
import { copyToClipboard } from '$lib/utils';
|
import { copyToClipboard } from '$lib/utils';
|
||||||
|
@ -113,6 +113,7 @@
|
||||||
onSubmit={onUserCreated}
|
onSubmit={onUserCreated}
|
||||||
onCancel={() => (shouldShowCreateUserForm = false)}
|
onCancel={() => (shouldShowCreateUserForm = false)}
|
||||||
onClose={() => (shouldShowCreateUserForm = false)}
|
onClose={() => (shouldShowCreateUserForm = false)}
|
||||||
|
oauthEnabled={$featureFlags.oauth}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue