File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
packages/clerk-js/src/core Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -2245,6 +2245,8 @@ export class Clerk implements ClerkInterface {
2245
2245
}
2246
2246
2247
2247
updateClient = ( newClient : ClientResource ) : void => {
2248
+ console . log ( { newClient, newStatus : newClient . sessions ?. [ 0 ] ?. status , currentStatus : this . session ?. status } ) ;
2249
+
2248
2250
if ( ! this . client ) {
2249
2251
// This is the first time client is being
2250
2252
// set, so we also need to set session
@@ -2258,6 +2260,23 @@ export class Clerk implements ClerkInterface {
2258
2260
if ( this . session ) {
2259
2261
const session = this . #getSessionFromClient( this . session . id ) ;
2260
2262
2263
+ const hasTransitionedToPendingStatus = this . session . status === 'active' && session ?. status === 'pending' ;
2264
+ if ( hasTransitionedToPendingStatus ) {
2265
+ const onBeforeSetActive : SetActiveHook =
2266
+ typeof window !== 'undefined' && typeof window . __unstable__onBeforeSetActive === 'function'
2267
+ ? window . __unstable__onBeforeSetActive
2268
+ : noop ;
2269
+
2270
+ const onAfterSetActive : SetActiveHook =
2271
+ typeof window !== 'undefined' && typeof window . __unstable__onAfterSetActive === 'function'
2272
+ ? window . __unstable__onAfterSetActive
2273
+ : noop ;
2274
+
2275
+ // Execute hooks to update server authentication context and trigger
2276
+ // page protections in clerkMiddleware or server components
2277
+ void Promise . resolve ( onBeforeSetActive ( ) ) . then ( ( ) => onAfterSetActive ( ) ) ;
2278
+ }
2279
+
2261
2280
// Note: this might set this.session to null
2262
2281
this . #setAccessors( session ) ;
2263
2282
You can’t perform that action at this time.
0 commit comments