2025-08-07 15:07:31 -04:00
|
|
|
<script lang="ts">
|
2025-11-14 20:10:44 +01:00
|
|
|
import { featureFlagsManager } from '$lib/managers/feature-flags-manager.svelte';
|
2026-01-09 13:03:57 -05:00
|
|
|
import { handleResetPinCode } from '$lib/services/user.service';
|
2026-02-19 16:50:39 -05:00
|
|
|
import { BasicModal, Field, FormModal, HelperText, PasswordInput, Stack, type ModalSize } from '@immich/ui';
|
2025-08-07 15:07:31 -04:00
|
|
|
import { mdiLockReset } from '@mdi/js';
|
|
|
|
|
import { t } from 'svelte-i18n';
|
|
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
onClose: (success?: true) => void;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let { onClose }: Props = $props();
|
|
|
|
|
|
|
|
|
|
let password = $state('');
|
|
|
|
|
|
2026-01-09 13:03:57 -05:00
|
|
|
const onSubmit = async () => {
|
|
|
|
|
const success = await handleResetPinCode({ password });
|
|
|
|
|
if (success) {
|
|
|
|
|
onClose();
|
2025-08-07 15:07:31 -04:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2026-01-09 13:03:57 -05:00
|
|
|
const common = $derived({ title: $t('reset'), size: 'small' as ModalSize, icon: mdiLockReset, onClose });
|
2025-08-07 15:07:31 -04:00
|
|
|
</script>
|
|
|
|
|
|
2026-02-19 16:50:39 -05:00
|
|
|
{#if featureFlagsManager.value.passwordLogin}
|
2026-01-09 13:03:57 -05:00
|
|
|
<FormModal {...common} submitColor="danger" submitText={$t('reset')} disabled={!password} {onSubmit}>
|
|
|
|
|
<Stack gap={4}>
|
|
|
|
|
<div>{$t('reset_pin_code_description')}</div>
|
|
|
|
|
<hr class="my-2 h-px w-full border-0 bg-gray-200 dark:bg-gray-600" />
|
|
|
|
|
<section>
|
|
|
|
|
<Field label={$t('confirm_password')} required>
|
|
|
|
|
<PasswordInput bind:value={password} autocomplete="current-password" />
|
|
|
|
|
<HelperText color="muted">{$t('reset_pin_code_with_password')}</HelperText>
|
|
|
|
|
</Field>
|
|
|
|
|
</section>
|
|
|
|
|
</Stack>
|
|
|
|
|
</FormModal>
|
|
|
|
|
{:else}
|
2026-02-19 16:50:39 -05:00
|
|
|
<BasicModal {...common}>
|
|
|
|
|
<div>{$t('reset_pin_code_description')}</div>
|
|
|
|
|
</BasicModal>
|
2026-01-09 13:03:57 -05:00
|
|
|
{/if}
|