summaryrefslogtreecommitdiff
path: root/ui/routes/(app)
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2024-10-29 23:29:22 -0400
committerOwen Jacobson <owen@grimoire.ca>2024-10-29 23:29:22 -0400
commit66d3fcf2e22f057bacce8d97d43a13c1c5a9ad09 (patch)
tree60995943e14a6568cf2b37622ce97df121865a6d /ui/routes/(app)
parente328d33fc7d6a0f2e3d260d8bddee3ef633318eb (diff)
Add `change password` UI + API.
The protocol here re-checks the caller's password, as a "I left myself logged in" anti-pranking check.
Diffstat (limited to 'ui/routes/(app)')
-rw-r--r--ui/routes/(app)/+layout.svelte4
-rw-r--r--ui/routes/(app)/me/+page.svelte41
2 files changed, 41 insertions, 4 deletions
diff --git a/ui/routes/(app)/+layout.svelte b/ui/routes/(app)/+layout.svelte
index 9abaaf4..08c6694 100644
--- a/ui/routes/(app)/+layout.svelte
+++ b/ui/routes/(app)/+layout.svelte
@@ -86,8 +86,4 @@
max-height: 100%;
overflow: scroll;
}
- #interface .active-channel {
- border: 1px solid grey;
- border-radius: 1.25rem;
- }
</style>
diff --git a/ui/routes/(app)/me/+page.svelte b/ui/routes/(app)/me/+page.svelte
new file mode 100644
index 0000000..fb612b8
--- /dev/null
+++ b/ui/routes/(app)/me/+page.svelte
@@ -0,0 +1,41 @@
+<script>
+ import { changePassword } from '$lib/apiServer.js';
+
+ import Invite from '$lib/components/Invite.svelte';
+
+ let currentPassword, newPassword, confirmPassword, passwordForm;
+ let pending = false;
+ $: valid = (newPassword === confirmPassword) && (newPassword !== currentPassword);
+ $: disabled = pending || !valid;
+
+ async function onPasswordChange() {
+ pending = true;
+ let response = await changePassword(currentPassword, newPassword);
+ switch (response.status) {
+ case 200:
+ passwordForm.reset();
+ break;
+ }
+ pending = false;
+ }
+</script>
+
+<form on:submit|preventDefault={onPasswordChange} bind:this={passwordForm} >
+ <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 variant-filled" type="submit" disabled={disabled}>
+ change password
+ </button>
+</form>
+
+<Invite />