From 8dd9f962be2aba1f95f4c6c25872d4dcd5b865cb Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Sun, 9 Oct 2022 12:11:38 -0500 Subject: [PATCH] add change-password dialog --- frontend/pages/profile.vue | 212 +++++++++++++++++++++++-------------- 1 file changed, 133 insertions(+), 79 deletions(-) diff --git a/frontend/pages/profile.vue b/frontend/pages/profile.vue index 165b489..a564844 100644 --- a/frontend/pages/profile.vue +++ b/frontend/pages/profile.vue @@ -192,78 +192,132 @@ token.value = data.token; } } + + const passwordChange = reactive({ + loading: false, + dialog: false, + current: "", + new: "", + isValid: false, + }); + + function openPassChange() { + passwordChange.dialog = true; + } + + async function changePassword() { + passwordChange.loading = true; + if (!passwordChange.isValid) { + return; + } + + const { error } = await api.user.changePassword(passwordChange.current, passwordChange.new); + + if (error) { + notify.error("Failed to change password."); + passwordChange.loading = false; + return; + } + + notify.success("Password changed successfully."); + passwordChange.dialog = false; + passwordChange.new = ""; + passwordChange.current = ""; + passwordChange.loading = false; + }