Skip to content

edit personal info and change password connected to backend#351

Open
adityapat24 wants to merge 1 commit intomainfrom
346-dev---update-profile-backendfrontend
Open

edit personal info and change password connected to backend#351
adityapat24 wants to merge 1 commit intomainfrom
346-dev---update-profile-backendfrontend

Conversation

@adityapat24
Copy link
Contributor

ℹ️ Issue

Closes #346

📝 Description

Connected edit personal information and change password in the settings page to the backend so that if the user decides to change parts of their profile, it is properly updated

Briefly list the changes made to the code:

  1. Added support for profile updates by updating the /auth/update-profile backend route and AuthService.updateProfile to handle first name, last name, and email changes across Cognito and DynamoDB, and connected it to the Settings page to call and sync it
  2. Added support for password changes by adding ChangePasswordBody, AuthService.changePassword, and a new /auth/change-password route and then connecting ChangePasswordModal to this endpoint with proper error handling

✔️ Verification

Made sure tests passed in backend and tested on frontend to see if changes worked as expected

Testing Edit Personal Information: Created dummy account with name as "Test Testing" which I then changed to "Aditya Pathak: Verified new first and last name in frontend
image

Testing Change Password: Testing changing password and logging in with new password, which worked. Also ensured that old password was not able to be used to login
Screenshot 2026-03-09 at 5 39 44 PM
Screenshot 2026-03-09 at 5 43 06 PM

Test Changes

I changed the describe('updateProfile') tests in auth.service.spec.ts, which previously called updateProfile(email, position_or_role). They now call updateProfile(accessToken, newEmail, firstName, lastName), mock Cognito getUser + DynamoDB get/update, and check the new validations (access token, email, first/last name) and the updated DynamoDB behavior

@adityapat24 adityapat24 linked an issue Mar 9, 2026 that may be closed by this pull request
Copy link
Collaborator

@lyannne lyannne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only a few comments but you slayed!

currentPassword: currentPassword.trim(),
newPassword,
});
handleClose();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you remove this?

Comment on lines -182 to +259
onSubmit={(values) => {
// Backend: call API with values.currentPassword and values.newPassword
void values;
onSubmit={async (values) => {
setChangePasswordError(null);
try {
const response = await api("/auth/change-password", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
currentPassword: values.currentPassword,
newPassword: values.newPassword,
}),
});

if (!response.ok) {
const errorBody = await response.json().catch(() => ({}));
const rawMessage =
(errorBody && (errorBody.message as string | string[])) || null;
const message = Array.isArray(rawMessage)
? rawMessage[0]
: rawMessage || "Failed to change password. Please try again.";
setChangePasswordError(message);
return;
}

setIsChangePasswordModalOpen(false);
} catch (error) {
console.error("Error changing password:", error);
setChangePasswordError(
"An unexpected error occurred. Please try again.",
);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be nice to take this out of the return statement of the component and have it as a handler above like the other methods?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^

setEditForm(updated);
}
}
}, [store.user, isEditingPersonalInfo]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the isEditingPersonalInfo variable ever change? idt it's necessary in this useEffect (worked fine without it when i ran it locally)! not sure if it's actually needed at all if it never changes to true

@prooflesben prooflesben requested a review from yumi520 March 13, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DEV - Update Profile Backend/Frontend

3 participants