@@ -129,7 +129,6 @@ export class WebAuthService extends EventEmitter<AuthServiceEvents> implements A
129129 private changeState ( newState : AuthState ) : void {
130130 const previousState = this . state
131131 this . state = newState
132- this . log ( `[auth] changeState: ${ previousState } -> ${ newState } ` )
133132 this . emit ( "auth-state-changed" , { state : newState , previousState } )
134133 }
135134
@@ -163,6 +162,8 @@ export class WebAuthService extends EventEmitter<AuthServiceEvents> implements A
163162 this . userInfo = null
164163
165164 this . changeState ( "logged-out" )
165+
166+ this . log ( "[auth] Transitioned to logged-out state" )
166167 }
167168
168169 private transitionToAttemptingSession ( credentials : AuthCredentials ) : void {
@@ -175,13 +176,17 @@ export class WebAuthService extends EventEmitter<AuthServiceEvents> implements A
175176 this . changeState ( "attempting-session" )
176177
177178 this . timer . start ( )
179+
180+ this . log ( "[auth] Transitioned to attempting-session state" )
178181 }
179182
180183 private transitionToInactiveSession ( ) : void {
181184 this . sessionToken = null
182185 this . userInfo = null
183186
184187 this . changeState ( "inactive-session" )
188+
189+ this . log ( "[auth] Transitioned to inactive-session state" )
185190 }
186191
187192 /**
@@ -417,6 +422,7 @@ export class WebAuthService extends EventEmitter<AuthServiceEvents> implements A
417422
418423 if ( previousState !== "active-session" ) {
419424 this . changeState ( "active-session" )
425+ this . log ( "[auth] Transitioned to active-session state" )
420426 this . fetchUserInfo ( )
421427 } else {
422428 this . state = "active-session"
@@ -563,7 +569,11 @@ export class WebAuthService extends EventEmitter<AuthServiceEvents> implements A
563569 ) ?. email_address
564570 }
565571
566- let extensionBridgeEnabled = true
572+ // Check for extension_bridge_enabled in user's public metadata
573+ let extensionBridgeEnabled = false
574+ if ( userData . public_metadata ?. extension_bridge_enabled === true ) {
575+ extensionBridgeEnabled = true
576+ }
567577
568578 // Fetch organization info if user is in organization context
569579 try {
@@ -579,7 +589,11 @@ export class WebAuthService extends EventEmitter<AuthServiceEvents> implements A
579589 if ( userMembership ) {
580590 this . setUserOrganizationInfo ( userInfo , userMembership )
581591
582- extensionBridgeEnabled = await this . isExtensionBridgeEnabledForOrganization ( storedOrgId )
592+ // Check organization public metadata for extension_bridge_enabled
593+ // Organization setting takes precedence over user setting
594+ if ( await this . isExtensionBridgeEnabledForOrganization ( storedOrgId ) ) {
595+ extensionBridgeEnabled = true
596+ }
583597
584598 this . log ( "[auth] User in organization context:" , {
585599 id : userMembership . organization . id ,
@@ -600,9 +614,10 @@ export class WebAuthService extends EventEmitter<AuthServiceEvents> implements A
600614 if ( primaryOrgMembership ) {
601615 this . setUserOrganizationInfo ( userInfo , primaryOrgMembership )
602616
603- extensionBridgeEnabled = await this . isExtensionBridgeEnabledForOrganization (
604- primaryOrgMembership . organization . id ,
605- )
617+ // Check organization public metadata for extension_bridge_enabled
618+ if ( await this . isExtensionBridgeEnabledForOrganization ( primaryOrgMembership . organization . id ) ) {
619+ extensionBridgeEnabled = true
620+ }
606621
607622 this . log ( "[auth] Legacy credentials: Found organization membership:" , {
608623 id : primaryOrgMembership . organization . id ,
0 commit comments