diff options
| author | Kit La Touche <kit@transneptune.net> | 2024-11-09 22:55:22 -0500 |
|---|---|---|
| committer | Kit La Touche <kit@transneptune.net> | 2024-11-09 22:55:22 -0500 |
| commit | 24eb775ba77f5a6a78a299d9fdffb34f8f167f8d (patch) | |
| tree | 32ab5163d55688dd90dc796aa44d94fec0b35c81 /ui/lib/components/ChangePassword.svelte | |
| parent | 91ce856f63bd1d7a188488476bdbec60b5bd58ff (diff) | |
| parent | a417c62edd4d3c07ba37b01835e89ed650489e09 (diff) | |
Merge branch 'main' into wip/touch-events
Diffstat (limited to 'ui/lib/components/ChangePassword.svelte')
| -rw-r--r-- | ui/lib/components/ChangePassword.svelte | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/ui/lib/components/ChangePassword.svelte b/ui/lib/components/ChangePassword.svelte new file mode 100644 index 0000000..1e48bee --- /dev/null +++ b/ui/lib/components/ChangePassword.svelte @@ -0,0 +1,60 @@ +<script> + import { changePassword } from '$lib/apiServer.js'; + + let currentPassword = $state(''), + newPassword = $state(''), + confirmPassword = $state(''), + pending = $state(false), + form; + let valid = $derived(newPassword === confirmPassword && newPassword !== currentPassword); + let disabled = $derived(pending || !valid); + + async function onsubmit(event) { + event.preventDefault(); + pending = true; + let response = await changePassword(currentPassword, newPassword); + switch (response.status) { + case 200: + form.reset(); + break; + } + pending = false; + } +</script> + +<form {onsubmit} bind:this={form}> + <label + >current password + <input + class="input" + name="currentPassword" + type="password" + placeholder="password" + bind:value={currentPassword} + /> + </label> + + <label + >new password + <input + class="input" + name="newPassword" + type="password" + placeholder="password" + bind:value={newPassword} + /> + </label> + + <label + >confirm new password + <input + class="input" + name="confirmPassword" + type="password" + placeholder="password" + bind:value={confirmPassword} + /> + </label> + + <button class="btn bg-orange-500 mt-4" type="submit" {disabled}>change password</button> +</form> |
