diff --git a/src/pages/AccountPage.tsx b/src/pages/AccountPage.tsx index ab2bf0f..cf77247 100644 --- a/src/pages/AccountPage.tsx +++ b/src/pages/AccountPage.tsx @@ -15,7 +15,6 @@ import { Provider, defaultTheme, } from "@adobe/react-spectrum"; - import { auth } from "../firebase/firebaseConfig"; const AccountPage: React.FC = () => { @@ -23,6 +22,7 @@ const AccountPage: React.FC = () => { const [lastName, setLastName] = useState(""); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); + const [reEnterPassword, setReEnterPassword] = useState(""); useEffect(() => { const user = auth.currentUser; @@ -51,6 +51,11 @@ const AccountPage: React.FC = () => { return; } + if (password !== reEnterPassword) { + alert("Passwords do not match. Please re-enter the password."); + return; + } + if (user) { try { if (`${firstName} ${lastName}` !== user.displayName) { @@ -60,12 +65,15 @@ const AccountPage: React.FC = () => { } if (email !== user.email) { - await updateEmail(user, email); + alert( + `A verification email has been sent to ${email}. Please verify it and then log back in to complete the update.` + ); await sendEmailVerification(user); + return; } await updatePassword(user, password); - alert("Account Updated!"); + alert("Account updated successfully!"); } catch (error) { console.error("Error updating account:", error); alert("An error occurred while updating the account."); @@ -83,17 +91,20 @@ const AccountPage: React.FC = () => { label="First name" value={firstName} onChange={setFirstName} + placeholder={firstName || "Enter first name"} /> { onChange={setPassword} isRequired /> +