diff --git a/src/stores/api/account.js b/src/stores/api/account.js index bb302423..6b1e8266 100644 --- a/src/stores/api/account.js +++ b/src/stores/api/account.js @@ -38,3 +38,21 @@ export async function APIResetPassword(key, newPassword, confirmPassword) { throw error; } } + +export async function APIUpdatePassword( + currentPassword, + newPassword, + confirmPassword +) { + try { + const data = await mainStore.callApi(`/user/updatePassword`, "POST", { + currentPassword: currentPassword, + newPassword: newPassword, + confirmPassword: confirmPassword, + }); + return data; + } catch (error) { + console.log("Error updating password:", error); + throw error; + } +} diff --git a/src/stores/main.js b/src/stores/main.js index c246db86..b3ee6997 100644 --- a/src/stores/main.js +++ b/src/stores/main.js @@ -122,6 +122,12 @@ export const useMainStore = defineStore("main", { this.isLoading = true; return null; } + if (response.data.status === "warn") { + alert(response.data.error_code); + this.isSaving = false; + this.isLoading = false; + return null; + } this.isLoading = false; // reset flags this.isSaving = false; return response.data; diff --git a/src/views/Profile/CardsView.vue b/src/views/Profile/CardsView.vue index 907d5b39..74fbaa76 100644 --- a/src/views/Profile/CardsView.vue +++ b/src/views/Profile/CardsView.vue @@ -1,10 +1,17 @@