feat(user): añadida función en services y stores para cambiar la contraseña

parent 0698af68
Showing with 13 additions and 1 deletions
......@@ -34,5 +34,9 @@ export const userService = {
update: async (updatedUser) => {
const response = await api.put('/user', updatedUser);
return response.data;
},
changePassword: async (oldPassword, newPassword) => {
const response = await api.patch(`user/password?oldPassword=${oldPassword}&newPassword=${newPassword}`);
return response.data;
}
}
\ No newline at end of file
......@@ -65,11 +65,18 @@ export const useUserStore = defineStore('user', {
},
async update(updatedUser) {
try {
const newUserData = userService.update(updatedUser);
const newUserData = await userService.update(updatedUser);
this.user = newUserData;
} catch (error) {
throw error;
}
},
async changePassword(oldPassword, newPassword) {
try {
await userService.changePassword(oldPassword, newPassword);
} catch (error) {
throw error;
}
}
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment