From 17d64be7fff17fe3c32f7d0d690029a8ae216ddb Mon Sep 17 00:00:00 2001
From: Nickj345 <118086990+Nickj345@users.noreply.github.com>
Date: Mon, 18 Nov 2024 11:58:26 -0600
Subject: [PATCH] Update AccountPage.tsx
---
src/pages/AccountPage.tsx | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/pages/AccountPage.tsx b/src/pages/AccountPage.tsx
index d47ee00..37c2e26 100644
--- a/src/pages/AccountPage.tsx
+++ b/src/pages/AccountPage.tsx
@@ -1,5 +1,5 @@
import React, { useState, useEffect } from 'react';
-import { updateProfile, updateEmail, sendEmailVerification } from 'firebase/auth';
+import { updateProfile, updateEmail, updatePassword, sendEmailVerification } from 'firebase/auth';
import { auth } from '../firebaseconfig';
import {
Button,
@@ -43,6 +43,12 @@ const AccountPage: React.FC = () => {
await sendEmailVerification(user);
}
+ // Update password if a new password is provided
+ if (password) {
+ await updatePassword(user, password);
+ alert('Password updated successfully.');
+ }
+
alert('Account information updated successfully.');
} catch (error) {
console.error("Error updating account information:", error);
@@ -74,10 +80,11 @@ const AccountPage: React.FC = () => {
onChange={setEmail}
/>