@@ -34,7 +34,9 @@ export interface ContextInterface {
34
34
/** Store given CurrentUser */
35
35
storeCurrentUser : ( currentUser : User ) => void ;
36
36
/** Function to get the currentUser */
37
- getSessionCurrentUser : ( ) => Promise < User | EmptyUser > ;
37
+ getSessionCurrentUser : (
38
+ forceUpdateCurrentUser ?: boolean
39
+ ) => Promise < User | EmptyUser > ;
38
40
}
39
41
40
42
interface SessionData {
@@ -204,10 +206,15 @@ const emptyCurrentUser: EmptyUser = {
204
206
} ;
205
207
206
208
export const getSessionCurrentUser = async (
207
- _storage : StorageManager
209
+ _storage : StorageManager ,
210
+ forceUpdateCurrentUser : boolean = false
208
211
) : Promise < User | EmptyUser > => {
209
212
const isStale = _storage . safeGetValue ( STALE_KEY ) ;
210
- if ( ! ( typeof isStale === "string" ) || ! ( isStale === "no" ) ) {
213
+ if (
214
+ forceUpdateCurrentUser ||
215
+ ! ( typeof isStale === "string" ) ||
216
+ ! ( isStale === "no" )
217
+ ) {
211
218
// If the session is stale, we need to refresh it
212
219
await updateCurrentUser ( _storage ) ;
213
220
}
@@ -262,8 +269,8 @@ export const getSessionContext = (
262
269
updateCurrentUser ( _storage ) ;
263
270
} ;
264
271
265
- const _getSessionCurrentUser = ( ) => {
266
- return getSessionCurrentUser ( _storage ) ;
272
+ const _getSessionCurrentUser = ( forceUpdateCurrentUser : boolean = false ) => {
273
+ return getSessionCurrentUser ( _storage , forceUpdateCurrentUser ) ;
267
274
} ;
268
275
269
276
if ( typeof window !== "undefined" ) {
0 commit comments