File tree 2 files changed +25
-3
lines changed
2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -87,12 +87,33 @@ export function updateCurrentUserEmail(
87
87
88
88
// @internal
89
89
type _UserState =
90
- // state 1 waiting for the initial load
90
+ // state 1 waiting for the initial load: [Promise, resolveFn]
91
91
| [ Promise < _Nullable < User > > , ( user : Ref < _Nullable < User > > ) => void ]
92
92
// state 2 loaded
93
93
| Ref < _Nullable < User > >
94
94
95
- const initialUserMap = new WeakMap < FirebaseApp , _UserState > ( )
95
+ /**
96
+ * Map of user promises based on the firebase application. Used by `getCurrentUser()` to return a promise that resolves
97
+ * the current user.
98
+ * @internal
99
+ */
100
+ export const initialUserMap = new WeakMap < FirebaseApp , _UserState > ( )
101
+
102
+ /**
103
+ * Forcibly sets the initial user state. This is used by the server auth module to set the initial user state and make
104
+ * `getCurrentUser()` work on the server during navigation and such.
105
+ *
106
+ * @internal
107
+ *
108
+ * @param firebaseApp - the firebase application
109
+ * @param user - the user to set
110
+ */
111
+ export function _setInitialUser (
112
+ firebaseApp : FirebaseApp ,
113
+ user : Ref < _Nullable < User > >
114
+ ) {
115
+ initialUserMap . set ( firebaseApp , user )
116
+ }
96
117
97
118
/**
98
119
* @internal
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { FirebaseApp } from 'firebase/app'
2
2
import { User } from 'firebase/auth'
3
3
import { UserRecord } from 'firebase-admin/auth'
4
4
import { App , ref } from 'vue'
5
- import { authUserMap } from '../auth/user'
5
+ import { authUserMap , _setInitialUser } from '../auth/user'
6
6
import { getGlobalScope } from '../globals'
7
7
import { _Nullable } from '../shared'
8
8
@@ -15,6 +15,7 @@ export function VueFireAuthServer(
15
15
ref < _Nullable < User > > ( createServerUser ( userRecord ) )
16
16
) !
17
17
authUserMap . set ( firebaseApp , user )
18
+ _setInitialUser ( firebaseApp , user )
18
19
}
19
20
20
21
/**
You can’t perform that action at this time.
0 commit comments