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