File tree Expand file tree Collapse file tree 3 files changed +11
-6
lines changed Expand file tree Collapse file tree 3 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,13 @@ import { firebaseConfig } from "../firebase/firebase.config";
11
11
12
12
initializeApp ( firebaseConfig ) ;
13
13
const auth = getAuth ( ) ;
14
+ auth . onAuthStateChanged ( function ( user ) { // Include to prevent loss of auth.currentUser upon page refresh
15
+ if ( user ) {
16
+ // User is signed in.
17
+ } else {
18
+ // No user is signed in.
19
+ }
20
+ } ) ;
14
21
15
22
interface SignupCredential {
16
23
user : UserCredential ;
Original file line number Diff line number Diff line change @@ -133,9 +133,7 @@ export function AuthContextProvider({ children }: AuthContextProviderProps) {
133
133
134
134
const removeAccount = useCallback ( async ( ) => {
135
135
try {
136
- if ( activeUser ) {
137
- await deleteUser ( ) ;
138
- }
136
+ await deleteUser ( ) ;
139
137
setUser ( undefined ) ;
140
138
setActiveUser ( undefined ) ;
141
139
navigate ( "/" , { replace : true } ) ;
Original file line number Diff line number Diff line change @@ -22,12 +22,12 @@ const style = {
22
22
} ;
23
23
24
24
const AccountDeletionForm = React . forwardRef ( function AccountDeletionForm ( ) {
25
- const { activeUser , removeAccount } = useAuth ( ) ;
25
+ const { user , removeAccount } = useAuth ( ) ;
26
26
27
27
const handleDelete = async ( ) => {
28
28
try {
29
- if ( activeUser ?. email ) {
30
- await deleteActiveUser ( activeUser . email ) ;
29
+ if ( user ?. email ) {
30
+ await deleteActiveUser ( user . email ) ;
31
31
await removeAccount ( ) ;
32
32
}
33
33
} catch ( e ) {
You can’t perform that action at this time.
0 commit comments