File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -87,12 +87,33 @@ export function updateCurrentUserEmail(
8787
8888// @internal
8989type _UserState =
90- // state 1 waiting for the initial load
90+ // state 1 waiting for the initial load: [Promise, resolveFn]
9191 | [ Promise < _Nullable < User > > , ( user : Ref < _Nullable < User > > ) => void ]
9292 // state 2 loaded
9393 | Ref < _Nullable < User > >
9494
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+ }
96117
97118/**
98119 * @internal
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { FirebaseApp } from 'firebase/app'
22import { User } from 'firebase/auth'
33import { UserRecord } from 'firebase-admin/auth'
44import { App , ref } from 'vue'
5- import { authUserMap } from '../auth/user'
5+ import { authUserMap , _setInitialUser } from '../auth/user'
66import { getGlobalScope } from '../globals'
77import { _Nullable } from '../shared'
88
@@ -15,6 +15,7 @@ export function VueFireAuthServer(
1515 ref < _Nullable < User > > ( createServerUser ( userRecord ) )
1616 ) !
1717 authUserMap . set ( firebaseApp , user )
18+ _setInitialUser ( firebaseApp , user )
1819}
1920
2021/**
You can’t perform that action at this time.
0 commit comments