File tree Expand file tree Collapse file tree 2 files changed +11
-12
lines changed
Expand file tree Collapse file tree 2 files changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -411,19 +411,13 @@ describe('auth', () => {
411411 const result = await withAuth ( createMockRequest ( 'wos-session=expired-session-data' ) ) ;
412412
413413 // Should warn about expired token
414- expect ( consoleWarnSpy ) . toHaveBeenCalledWith ( 'Access token expired for user' ) ;
414+ expect ( consoleWarnSpy ) . toHaveBeenCalledWith (
415+ '[AuthKit] Access token expired. Ensure authkitLoader is used in a parent/root route to handle automatic token refresh.' ,
416+ ) ;
415417
416- // Result should still contain user info
418+ // Result should return null user when token is expired
417419 expect ( result ) . toEqual ( {
418- user : mockSession . user ,
419- sessionId : mockClaims . sessionId ,
420- organizationId : mockClaims . organizationId ,
421- role : mockClaims . role ,
422- permissions : mockClaims . permissions ,
423- entitlements : mockClaims . entitlements ,
424- featureFlags : mockClaims . featureFlags ,
425- impersonator : undefined ,
426- accessToken : mockSession . accessToken ,
420+ user : null ,
427421 } ) ;
428422
429423 consoleWarnSpy . mockRestore ( ) ;
Original file line number Diff line number Diff line change @@ -57,7 +57,12 @@ export async function withAuth(args: LoaderFunctionArgs): Promise<UserInfo | NoU
5757 if ( Date . now ( ) >= exp * 1000 ) {
5858 // The access token is expired. This function does not handle token refresh.
5959 // Ensure that token refresh is implemented in the parent/root loader as documented.
60- console . warn ( 'Access token expired for user' ) ;
60+ console . warn (
61+ '[AuthKit] Access token expired. Ensure authkitLoader is used in a parent/root route to handle automatic token refresh.' ,
62+ ) ;
63+ return {
64+ user : null ,
65+ } ;
6166 }
6267
6368 return {
You can’t perform that action at this time.
0 commit comments