From 0218a040572d8fb3877f52bc5dcf1a846dadfc06 Mon Sep 17 00:00:00 2001 From: Husein Jusic Date: Mon, 12 Aug 2024 23:39:56 +0200 Subject: [PATCH] feat: add simple change password field --- admin-ui/src/routes/+page.svelte | 20 +++++++++++++ admin-ui/src/routes/file/+page.svelte | 0 .../src/store/users/util/changePassword.ts | 29 +++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 admin-ui/src/routes/file/+page.svelte create mode 100644 admin-ui/src/store/users/util/changePassword.ts diff --git a/admin-ui/src/routes/+page.svelte b/admin-ui/src/routes/+page.svelte index e270706..6de56ba 100644 --- a/admin-ui/src/routes/+page.svelte +++ b/admin-ui/src/routes/+page.svelte @@ -1,7 +1,19 @@
@@ -19,5 +31,13 @@ {}} />
+ \ No newline at end of file diff --git a/admin-ui/src/routes/file/+page.svelte b/admin-ui/src/routes/file/+page.svelte new file mode 100644 index 0000000..e69de29 diff --git a/admin-ui/src/store/users/util/changePassword.ts b/admin-ui/src/store/users/util/changePassword.ts new file mode 100644 index 0000000..de43b89 --- /dev/null +++ b/admin-ui/src/store/users/util/changePassword.ts @@ -0,0 +1,29 @@ +import { useGraphql } from "../../utils/useGraphQl"; +import { loggedInUser } from "../../auth/store"; +import { get } from 'svelte/store'; +import { users } from "../store"; +import { User } from "../User"; + +const changePasswordMutation = ` + mutation($oldPassword: String, $newPassword: String){ + changePassword(oldPassword: $oldPassword, newPassword: $newPassword) + } +`; + +export const changePassword = async (oldPassword: string, newPassword: string) => { + let response = await useGraphql( + changePasswordMutation, + { + oldPassword, + newPassword + }, + get(loggedInUser)); + + if(response.errors) { + throw "could not change password" + } + + console.log(response) + + return true +} \ No newline at end of file