Skip to content

Commit c42eec1

Browse files
committed
Cloud: use the existing auth event flow to handle org switching
1 parent d20a644 commit c42eec1

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

packages/cloud/src/WebAuthService.ts

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ export class WebAuthService extends EventEmitter<AuthServiceEvents> implements A
175175

176176
this.changeState("attempting-session")
177177

178+
this.timer.stop()
178179
this.timer.start()
179180
}
180181

@@ -485,26 +486,8 @@ export class WebAuthService extends EventEmitter<AuthServiceEvents> implements A
485486
organizationId: organizationId,
486487
}
487488

488-
// Store the updated credentials
489+
// Store the updated credentials, handleCredentialsChange will handle the update
489490
await this.storeCredentials(updatedCredentials)
490-
491-
// Update the local credentials
492-
this.credentials = updatedCredentials
493-
494-
// Clear the current session token to force a refresh with new org context
495-
this.sessionToken = null
496-
497-
// Trigger a session refresh to get a new token with the correct org context
498-
try {
499-
await this.refreshSession()
500-
// Fetch updated user info after organization switch to reflect new context
501-
await this.fetchUserInfo()
502-
} catch (error) {
503-
this.log(`[auth] Failed to refresh session after organization switch: ${error}`)
504-
// Even if refresh fails, the credentials are updated for next attempt
505-
}
506-
507-
this.log(`[auth] Switched organization context to: ${organizationId || "personal account"}`)
508491
}
509492

510493
/**

0 commit comments

Comments
 (0)