Skip to content

Commit

Permalink
get email from localstorage
Browse files Browse the repository at this point in the history
  • Loading branch information
trinity-y committed Nov 13, 2024
1 parent d8263b3 commit d52c800
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
3 changes: 2 additions & 1 deletion frontend/src/APIClients/AuthAPIClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,15 @@ const refresh = async (): Promise<boolean> => {

// // trinity did this VV
const setPassword = async (
email: string,
newPassword: string,
): Promise<PasswordSetResponse> => {
const bearerToken = `Bearer ${getLocalStorageObjProperty(
AUTHENTICATED_USER_KEY,
"accessToken",
)}`;
try {
const email = getLocalStorageObjProperty(AUTHENTICATED_USER_KEY, "email")
// set password
const response = await baseAPIClient.post(
`/auth/setPassword/${email}`,
{ newPassword },
Expand Down
18 changes: 11 additions & 7 deletions frontend/src/components/pages/CreatePasswordPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,18 @@ const CreatePasswordPage = (): React.ReactElement => {
if (validatePasswords()) {
return;
}

// whoever is handling the email thing needs to pass in the email
AuthAPIClient.setPassword("[email protected]", password).then((resetPasswordResponse)=> {
if (resetPasswordResponse.success) {
setShowModal(true);
}
})

AuthAPIClient.setPassword(password).then(
(resetPasswordResponse) => {
if (resetPasswordResponse.success) {
setShowModal(true);
} else if (resetPasswordResponse.errorMessage) {
setPasswordError(resetPasswordResponse.errorMessage);
} else {
setPasswordError("An unknown error occured. Please try again later.")
}
},
);
};
return (
<Flex
Expand Down

0 comments on commit d52c800

Please sign in to comment.