mirror of
https://github.com/immich-app/immich.git
synced 2025-06-01 20:56:38 -04:00
* feat(web): improve /auth pages * invalidate load functions after login * handle login server errors more graceful * add loading state to oauth button
84 lines
1.8 KiB
Svelte
84 lines
1.8 KiB
Svelte
<script lang="ts">
|
|
import { api, UserResponseDto } from '@api';
|
|
import { createEventDispatcher } from 'svelte';
|
|
|
|
export let user: UserResponseDto;
|
|
let error: string;
|
|
let success: string;
|
|
|
|
let password = '';
|
|
let confirmPassowrd = '';
|
|
|
|
let changeChagePassword = false;
|
|
|
|
$: {
|
|
if (password !== confirmPassowrd && confirmPassowrd.length > 0) {
|
|
error = 'Password does not match';
|
|
changeChagePassword = false;
|
|
} else {
|
|
error = '';
|
|
changeChagePassword = true;
|
|
}
|
|
}
|
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
async function changePassword() {
|
|
if (changeChagePassword) {
|
|
error = '';
|
|
|
|
const { status } = await api.userApi.updateUser({
|
|
id: user.id,
|
|
password: String(password),
|
|
shouldChangePassword: false
|
|
});
|
|
|
|
if (status === 200) {
|
|
dispatch('success');
|
|
return;
|
|
} else {
|
|
console.error('Error changing password');
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<form on:submit|preventDefault={changePassword} method="post" class="flex flex-col gap-5 mt-5">
|
|
<div class="flex flex-col gap-2">
|
|
<label class="immich-form-label" for="password">New Password</label>
|
|
<input
|
|
class="immich-form-input"
|
|
id="password"
|
|
name="password"
|
|
type="password"
|
|
autocomplete="new-password"
|
|
required
|
|
bind:value={password}
|
|
/>
|
|
</div>
|
|
|
|
<div class="flex flex-col gap-2">
|
|
<label class="immich-form-label" for="confirmPassword">Confirm Password</label>
|
|
<input
|
|
class="immich-form-input"
|
|
id="confirmPassword"
|
|
name="password"
|
|
type="password"
|
|
autocomplete="current-password"
|
|
required
|
|
bind:value={confirmPassowrd}
|
|
/>
|
|
</div>
|
|
|
|
{#if error}
|
|
<p class="text-red-400 text-sm">{error}</p>
|
|
{/if}
|
|
|
|
{#if success}
|
|
<p class="text-immich-primary text-sm">{success}</p>
|
|
{/if}
|
|
<div class="my-5 flex w-full">
|
|
<button type="submit" class="immich-btn-primary-big">Change Password</button>
|
|
</div>
|
|
</form>
|