Skip to content

Commit

Permalink
Update AccountPage.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
Nickj345 authored Nov 18, 2024
1 parent e59a02f commit 17d64be
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/pages/AccountPage.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -74,10 +80,11 @@ const AccountPage: React.FC = () => {
onChange={setEmail}
/>
<TextField
label="Password"
label="New Password"
type="password"
value={password}
onChange={setPassword}
placeholder="Leave blank to keep current password"
/>
<Button variant="cta" onPress={handleUpdate}>Update</Button>
</Flex>
Expand Down

0 comments on commit 17d64be

Please sign in to comment.