fix: after auth login, just WAIT for Teams redirect chain to complete (do NOT navigate back to meeting URL)

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
ValueOn AG 2026-02-16 13:35:26 +01:00
parent 5d2335dd26
commit 325de1c9ae

View file

@ -213,32 +213,26 @@ export class BotOrchestrator {
if (authSuccess) {
this._logger.info('Authentication via "Sign in" link succeeded');
await this._page!.waitForTimeout(3000);
const postAuthUrl = this._page!.url();
this._logger.info(`Post-auth URL: ${postAuthUrl.substring(0, 100)}`);
// After login, Teams does a redirect chain automatically:
// Login → M365 → Teams v2 → Pre-Join page (/v2/)
// Do NOT navigate anywhere. Just wait for the redirect chain to complete
// and for the "Join now" button to appear on the Teams v2 pre-join page.
this._logger.info('Waiting for Teams to redirect to authenticated pre-join page...');
// After login, Microsoft redirects to M365 (m365.cloud.microsoft/chat/).
// Navigate back to the meeting URL. Now with auth cookies set,
// clicking "Continue on this browser" should lead to the authenticated
// Teams v2 Pre-Join page (with meeting title, no name input, "Room audio" option).
this._logger.info('Navigating back to meeting URL after auth...');
await this._page!.goto(this._meetingUrl, {
waitUntil: 'domcontentloaded',
timeout: 30000,
});
// Click "Continue on this browser" - this time with auth cookies
// it should lead to the authenticated pre-join page
await this._joinProcedure!.handleLauncherIfPresent();
// Wait for Teams v2 pre-join page to load
await this._page!.waitForTimeout(8000);
const postNavUrl = this._page!.url();
const postNavContent = await this._page!.evaluate(() => document.body?.innerText?.substring(0, 300) || '');
this._logger.info(`Post-auth navigation URL: ${postNavUrl.substring(0, 100)}`);
this._logger.info(`Post-auth page content: ${postNavContent.substring(0, 200)}`);
// Wait for the #prejoin-join-button to appear (up to 30 seconds)
// This button only exists on the Teams v2 authenticated pre-join page
const joinButtonSelector = '#prejoin-join-button, button[data-tid="prejoin-join-button"]';
try {
await this._page!.waitForSelector(joinButtonSelector, { timeout: 30000, state: 'visible' });
const currentUrl = this._page!.url();
this._logger.info(`Arrived at authenticated pre-join page: ${currentUrl.substring(0, 80)}`);
} catch {
const currentUrl = this._page!.url();
const pageContent = await this._page!.evaluate(() => document.body?.innerText?.substring(0, 300) || '');
this._logger.warn(`Join button not found after auth redirect. URL: ${currentUrl.substring(0, 80)}`);
this._logger.warn(`Page content: ${pageContent.substring(0, 200)}`);
}
// Verify we're on the authenticated pre-join page
const pageText = await this._page!.evaluate(() => document.body?.innerText?.substring(0, 500) || '');