mirror of
https://github.com/immich-app/immich.git
synced 2024-11-15 09:59:00 -07: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
@ -62,7 +62,6 @@ export class UserAdminCreateDto {
|
||||
@Transform(toEmail)
|
||||
email!: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
password!: string;
|
||||
|
||||
|
@ -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', {
|
||||
|
@ -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">
|
||||
|
@ -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}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user