edit personal info and change password connected to backend#351
Open
adityapat24 wants to merge 1 commit intomainfrom
Open
edit personal info and change password connected to backend#351adityapat24 wants to merge 1 commit intomainfrom
adityapat24 wants to merge 1 commit intomainfrom
Conversation
lyannne
requested changes
Mar 13, 2026
Collaborator
lyannne
left a comment
There was a problem hiding this comment.
only a few comments but you slayed!
| currentPassword: currentPassword.trim(), | ||
| newPassword, | ||
| }); | ||
| handleClose(); |
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.", | ||
| ); | ||
| } |
Collaborator
There was a problem hiding this comment.
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?
| setEditForm(updated); | ||
| } | ||
| } | ||
| }, [store.user, isEditingPersonalInfo]); |
Collaborator
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ℹ️ 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:
✔️ 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

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


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