Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to redirect using router #2869

Closed
3 of 10 tasks
jamesots opened this issue Jan 13, 2021 · 2 comments · Fixed by #2985
Closed
3 of 10 tasks

Add ability to redirect using router #2869

jamesots opened this issue Jan 13, 2021 · 2 comments · Fixed by #2985
Assignees
Labels
feature Feature requests. msal-react Related to @azure/msal-react

Comments

@jamesots
Copy link

Library

  • msal@1.x.x or @azure/msal@1.x.x
  • @azure/msal-browser@2.8.0
  • @azure/msal-node@1.x.x
  • @azure/msal-react@1.0.0-alpha.1
  • @azure/msal-angular@0.x.x
  • @azure/msal-angular@1.x.x
  • @azure/msal-angular@2.x.x
  • @azure/msal-angularjs@1.x.x

Description

When doing a login or token acquisition using redirect, the login server redirects back to
the redirectUri, before then redirecting to the last used url or the redirectStartPage location.
As far as I can tell, it always uses window.location.replace/assign in BrowserUtils at the moment.
It would be really helpful if I could hook into this somehow and instead use my router's navigate
method, so that my SPA doesn't have to be reloaded again!

I'm currently doing this by setting navigateToLoginRequestUrl to false and adding an event
handler to try and do the same kind of thing myself. (i.e. storing the URL in localStorage
when the interactionType is redirect and the eventType is msal:loginStart or
msal:acquireTokenStart, and then navigating when the eventType is
msal:handleRedirectEnd. It appears to work, but doesn't seem like something I should
need to be doing).

Source

  • Internal (Microsoft)
  • Customer request
@jamesots jamesots added the feature Feature requests. label Jan 13, 2021
@tnorling tnorling added the msal-react Related to @azure/msal-react label Jan 13, 2021
@tnorling
Copy link
Collaborator

@jamesots Thanks for the suggestion. With the way handleRedirectPromise is currently designed doing something like this would be challenging. Even if we provide a way to override the method used to redirect you would then run into issues processing the token response. We'll take this under consideration and think about how something like this could be implemented cleanly but for now, what you've described above is in line with our recommendation for handling this scenario. We also welcome PRs if you have a solution in mind!

@tnorling
Copy link
Collaborator

tnorling commented Mar 4, 2021

@jamesots This feature was just released in msal-browser@2.12.0, you can find docs here

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature Feature requests. msal-react Related to @azure/msal-react
Projects
None yet
2 participants