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; + }