AzureAD / microsoft-authentication-library-for-js

Microsoft Authentication Library (MSAL) for JS
http://aka.ms/aadv2
MIT License
3.64k stars 2.65k forks source link

Provide reference to popup #2626

Closed kevindelange closed 3 years ago

kevindelange commented 3 years ago

Library

@azure/msal-browser@2.x.x

Description

Hi,

It would be awesome if we could have a reference to the popup (loginPopup method, which eventually fire's a window.open()).

In the current state I believe there is no way we can acces this reference in our (angular 10) application, using msal-browser.

When the popup opens with a B2C policy, it may happen that the popup gets lost by the user. When they then try to open the popup again (for instance, to login or change account details), an error gets thrown: interaction_in_progress. This is because the popup is already open. It would be nice to have a reference to the popup, so we can close it, before opening it again.

I'm sorry if i've missed the option to get the reference, or cancel a policy if there's an active one.

jasonnutter commented 3 years ago

When the popup opens with a B2C policy, it may happen that the popup gets lost by the user.

Can you please clarify what you mean by "gets lost?"

kevindelange commented 3 years ago

When the popup opens with a B2C policy, it may happen that the popup gets lost by the user.

Can you please clarify what you mean by "gets lost?"

Clicking next to the popup, so it's not visible anymore may happen (by accident), and then when you try to open it again, because you think it's gone, breaks the flow.

Also, when in need of supplying an authorization code from an email in the popup, and switching to another tab (to copy over the email) it can be confusing for some people that this popup is still open. Mainly because it's a new smaller window, and not an open tab.

The way we currently solved this, is checking if a popup is opened by the user, and then if they click the button again (while a popup is active) we refresh the page. It will probably won't happen that often, but this workaround is not so nice. I think it would be better if we could have a reference to the popup, so we can cancel the window.open() before opening a new one.

If there are other solutions to this problem that I am not aware of, could you please point them out? I haven't found any.

jasonnutter commented 3 years ago

Update: we're working on some improvements to how popups are handled (#2842), and will fix this scenario incrementally where the same popup request is made twice in a row.

pkanher617 commented 3 years ago

@kevindelange Have you been able to try out this scenario since the PR referenced above was merged?