question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Auto Redirect for login

See original GitHub issue

Library

  • msal@1.x.x or @azure/msal@1.x.x
  • @azure/msal-browser@2.11.0
  • @azure/msal-node@1.x.x
  • @azure/msal-react@1.x.x
  • @azure/msal-angular@0.x.x
  • @azure/msal-angular@1.x.x
  • @azure/msal-angular@2.0.0-alpha.6
  • @azure/msal-angularjs@1.x.x

Description

I have followed this repos. In fact. I downloaded the code, added a controller to the API and am making calls to the new controller.

I would like to know if it’s possible in the Angular App to not have the user click on a login button to redirect to the Microsoft Login Page?

I have attempted this on my own in the angular app, by doing the following: In the app.component.ts file, in the ngOnInit() method. I added a call to this.login(); above the line this.checkAccount();

The angular app, will auto redirect to the Microsoft Login Page automatically, I can login and it will take me to the default page based on the routing map.

The odd behavior I see is once I’m on the default page if I click the browser refresh button, the page will just automatically start a refresh loop. It will do this refresh until you stop it. When it does this, I see in the console the error thats described in this issue: #3042

I have read through the comments and see where a MsalRedirectComponent has been introduced, would this solve my problem?

If so, can I get a link to a sample that uses the MsalRedirectComponent or the documentation for it? The comments in 3042 mention a linked sample page, but I don’t see a link.

I’m attaching my modified sample project for review.

Ideally I do not want the user to have to click a login button to get to the the Microsoft Login Page

Thanks

ModifiedSampleApp.zip

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
rellis-of-rhindletoncommented, Mar 25, 2021

Adding an 'auth' path to your routes, setting the MsalRedirectComponent as the component (this route should not be protected by the MsalGuard

/smacksownhead

Of course. Makes sense now. I was doing the right thing, then, but the hard way. Thanks.

1reaction
jo-arroyocommented, Mar 24, 2021

@rellis-of-rhindleton @sidyes Thanks again for your feedback. We have just released a new version of @azure/msal-angular with updated guidance and samples regarding login on app load for path and hash routing, hope this helps. If you are still experiencing issues with this, please try out the new versions and open a new issue with your configuration and usage.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to redirect and auto login user - Stack Overflow
I've been asked to make it so that when customers are redirected to the correct site that they are also auto logged in...
Read more >
How to auto redirect to the provider login screen #4078 - GitHub
The issue is that I want to automatically redirect to the Okta login screen without having a user to click on the login...
Read more >
Redirect Automatically to SSO IdP Authentication from the ...
The Login (/login.do) page is a public page by-design, to enable login using local (User[sys_user]) accounts. If this isn't the required behaviour it...
Read more >
Laravel: Auto-Redirect to Login in Breeze or Jetstream
What if you want to get rid of the default Laravel homepage and automatically redirect to the login form? It's easy, I will...
Read more >
How to Router Redirect After Login - Pluralsight
In this guide, we are going to learn how to redirect a user after a successful login. ... The login form has two...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found