OfficeDev / microsoft-teams-library-js

JavaScript library for use by Microsoft Teams apps
https://docs.microsoft.com/microsoftteams/platform/
Other
430 stars 199 forks source link

While clicking a Web App URL via outlook mail the new window tab auto-closes itself post authentication with same user credentials #2036

Closed Digvijayrao-KF closed 11 months ago

Digvijayrao-KF commented 1 year ago

Problem Statement Once the browser has a MS account logged-in, in Tab1 say outlook mail and user tries to open a URL from mail body that redirects to another web app URL with the same MS account, the tab auto-closes itself. When user clicks the URL again, it works and he is landed to application dashboard successfully (without getting the login screen)

Steps to re-create the issue Step1: Login the user with domain from Microsoft to outlook mail in Tab1. Step2: One of the mail in inbox must have a web app URL that consists of a custom login page. Step3: Post we enter the same user mail from Step1 (Note: Since we are using msal authentication, it will not ask the password again, it will be considered from the outlook tab) it auto closes the new window i.e Tab2 opened in the same browser, considering it as a child window & not the parent one.

The issue was observed in the source code taken from v1.11.0

In the below source code, setTimeout func executes

export function notifySuccess(result?: string, callbackUrl?: string): void {
  redirectIfWin32Outlook(callbackUrl, "result", result);
  ensureInitialized(FrameContexts.authentication);
  sendMessageToParent("authentication.authenticate.success", [result]);
  // Wait for the message to be sent before closing the window
  waitForMessageQueue(Communication.parentWindow, () =>
    setTimeout(() => Communication.currentWindow.close(), 200)
  );
}

NOTE: If we manually open the Web App URL in Tab2 without clicking the URL from mail body it works fine.

Packages Consumed

  "@azure/msal-browser": "^2.22.1",
  "@azure/msal-react": "^1.3.1",
  "@microsoft/mgt-element": "^3.1.3",
  "@microsoft/mgt-react": "^3.1.3",
  "@microsoft/signalr": "^6.0.8",
  "@microsoft/teams-js": "^1.11.0"
nwojod-MSFT commented 1 year ago

Thanks @Digvijayrao-KF for reporting this issue. We will try this on our end using the repro step and get back to you.

sayali-MSFT commented 1 year ago

@Digvijayrao-KF - Thanks for reporting your issue. We will check this at our end and will get back to you.

sayali-MSFT commented 12 months ago

@Digvijayrao-KF - We are trying to reproduce the issue and encountering some difficulties while doing so. If possible, could you please share the small video or images so that it is helpful for replicate the scenario.

microsoft-github-policy-service[bot] commented 11 months ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 3 days. It will be closed if no further activity occurs within 3 days of this comment.