Skip to content

Commit

Permalink
frontend: profile - change password - wip
Browse files Browse the repository at this point in the history
  • Loading branch information
rkshaon committed Jul 26, 2024
1 parent 9054a9c commit 6a7d516
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
5 changes: 5 additions & 0 deletions backend/user_api/views/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ def put(self, request, *args, **kwargs):
new_password = request.data.get('new_password', None)

if not old_password or not new_password:
print(request.data)
print("old and new same")
return Response({
'errors': [
'Old password or new password can not be empty',
Expand All @@ -145,13 +147,16 @@ def put(self, request, *args, **kwargs):
user = request.user

if not user.check_password(old_password):
print("old password does not match.")
return Response({
'errors': [
'Old password does not matched!',
]
}, status=status.HTTP_400_BAD_REQUEST)

if old_password == new_password:
print(request.data)
print("old is used")
return Response({
'errors': [
'Old password is used!',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default {
async confirmUpdate() {
console.log('Confirm update function called.');
const toast = useToast();
console.log(this.changePasswordData);
console.log('data:', this.changePasswordData);
toast.info("work in progress");
try {
Expand All @@ -91,9 +91,9 @@ export default {
toast.error('Failed to create category.');
}
const modalElement = this.$refs.changePasswordModal;
const modal = new Modal(modalElement);
modal._hideModal();
// const modalElement = this.$refs.changePasswordModal;
// const modal = new Modal(modalElement);
// modal._hideModal();
},
}
}
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/services/userAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,14 @@ export const getUserProfile = () => {
return apiClient.get("/api/v1/users/profile");
};

export const changePassword = () => {
return apiClient.put("/api/v1/users/changepassword");
export const changePassword = (data) => {
console.log('service: ', data);
return apiClient.put("/api/v1/users/changepassword", data);
// return apiClient.post("/api/v1/categories/", categoryData, {
// headers: {
// "Content-Type": "multipart/form-data",
// },
// });
};

export default {};
2 changes: 1 addition & 1 deletion frontend/src/store/modules/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const actions = {

async changePassword() {
const response = await changePassword();
console.log(response.data);
console.log("response in store: ", response.data);
},
};

Expand Down

0 comments on commit 6a7d516

Please sign in to comment.