mirror of
https://github.com/immich-app/immich.git
synced 2025-06-01 20:54:22 -04:00
* Added password field visibility toggle * improvements to password input field * fix e2e and change tabindex * add missing name=password * remove unnecessary type prop --------- Co-authored-by: Jan108 <dasJan108@gmail.com> Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com>
81 lines
2.3 KiB
Svelte
81 lines
2.3 KiB
Svelte
<script lang="ts">
|
|
import {
|
|
notificationController,
|
|
NotificationType,
|
|
} from '$lib/components/shared-components/notification/notification';
|
|
import { changePassword } from '@immich/sdk';
|
|
import { fade } from 'svelte/transition';
|
|
|
|
import Button from '$lib/components/elements/buttons/button.svelte';
|
|
import type { HttpError } from '@sveltejs/kit';
|
|
import SettingInputField, {
|
|
SettingInputFieldType,
|
|
} from '$lib/components/shared-components/settings/setting-input-field.svelte';
|
|
|
|
let password = '';
|
|
let newPassword = '';
|
|
let confirmPassword = '';
|
|
|
|
const handleChangePassword = async () => {
|
|
try {
|
|
await changePassword({ changePasswordDto: { password, newPassword } });
|
|
|
|
notificationController.show({
|
|
message: 'Updated password',
|
|
type: NotificationType.Info,
|
|
});
|
|
|
|
password = '';
|
|
newPassword = '';
|
|
confirmPassword = '';
|
|
} catch (error) {
|
|
console.error('Error [user-profile] [changePassword]', error);
|
|
notificationController.show({
|
|
message: (error as HttpError)?.body?.message || 'Unable to change password',
|
|
type: NotificationType.Error,
|
|
});
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<section class="my-4">
|
|
<div in:fade={{ duration: 500 }}>
|
|
<form autocomplete="off" on:submit|preventDefault>
|
|
<div class="ml-4 mt-4 flex flex-col gap-4">
|
|
<SettingInputField
|
|
inputType={SettingInputFieldType.PASSWORD}
|
|
label="PASSWORD"
|
|
bind:value={password}
|
|
required={true}
|
|
passwordAutocomplete="current-password"
|
|
/>
|
|
|
|
<SettingInputField
|
|
inputType={SettingInputFieldType.PASSWORD}
|
|
label="NEW PASSWORD"
|
|
bind:value={newPassword}
|
|
required={true}
|
|
passwordAutocomplete="new-password"
|
|
/>
|
|
|
|
<SettingInputField
|
|
inputType={SettingInputFieldType.PASSWORD}
|
|
label="CONFIRM PASSWORD"
|
|
bind:value={confirmPassword}
|
|
required={true}
|
|
passwordAutocomplete="new-password"
|
|
/>
|
|
|
|
<div class="flex justify-end">
|
|
<Button
|
|
type="submit"
|
|
size="sm"
|
|
disabled={!(password && newPassword && newPassword === confirmPassword)}
|
|
on:click={() => handleChangePassword()}>Save</Button
|
|
>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</section>
|