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', () => {
411
411
const result = await withAuth ( createMockRequest ( 'wos-session=expired-session-data' ) ) ;
412
412
413
413
// 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
+ ) ;
415
417
416
- // Result should still contain user info
418
+ // Result should return null user when token is expired
417
419
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 ,
427
421
} ) ;
428
422
429
423
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
57
57
if ( Date . now ( ) >= exp * 1000 ) {
58
58
// The access token is expired. This function does not handle token refresh.
59
59
// 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
+ } ;
61
66
}
62
67
63
68
return {
You can’t perform that action at this time.
0 commit comments