@@ -34,7 +34,9 @@ export interface ContextInterface {
3434 /** Store given CurrentUser */
3535 storeCurrentUser : ( currentUser : User ) => void ;
3636 /** Function to get the currentUser */
37- getSessionCurrentUser : ( ) => Promise < User | EmptyUser > ;
37+ getSessionCurrentUser : (
38+ forceUpdateCurrentUser ?: boolean
39+ ) => Promise < User | EmptyUser > ;
3840}
3941
4042interface SessionData {
@@ -204,10 +206,10 @@ const emptyCurrentUser: EmptyUser = {
204206} ;
205207
206208export const getSessionCurrentUser = async (
207- _storage : StorageManager
209+ _storage : StorageManager ,
210+ forceUpdateCurrentUser : boolean = false
208211) : Promise < User | EmptyUser > => {
209- const isStale = _storage . safeGetValue ( STALE_KEY ) ;
210- if ( ! ( typeof isStale === "string" ) || ! ( isStale === "no" ) ) {
212+ if ( forceUpdateCurrentUser || _storage . safeGetValue ( STALE_KEY ) === "yes" ) {
211213 // If the session is stale, we need to refresh it
212214 await updateCurrentUser ( _storage ) ;
213215 }
@@ -262,8 +264,8 @@ export const getSessionContext = (
262264 updateCurrentUser ( _storage ) ;
263265 } ;
264266
265- const _getSessionCurrentUser = ( ) => {
266- return getSessionCurrentUser ( _storage ) ;
267+ const _getSessionCurrentUser = ( forceUpdateCurrentUser : boolean = false ) => {
268+ return getSessionCurrentUser ( _storage , forceUpdateCurrentUser ) ;
267269 } ;
268270
269271 if ( typeof window !== "undefined" ) {
0 commit comments