login at a particular route "/login"
Can we change the default login at route "/" to "/login" for the application?
Could you elaborate on this? Currently the behaviour is that whatever you have wrapped in makeAuthenticator will always redirect you to the login page if you are not logged in.
like currently if we put out web url like www.xyz.com, it redirects to azure login but if we want for application to login only on the click of a button, how should we do it.
now when we enter www.xyz.com, it should first redirect to welcome page where on click of a button it should perform the login step.
I have the exact same question, I can't figure out how to do it.
Currenly the OIDC login flow is triggered when the 'AppWithAuth' component is mounted. It will either redirect to the IdentityServer login page, or detect that the user is already logged in and give access to the protected wrapped component. That works as advertised.
What I would like is to have a 'Login' button in my UI, which would trigger the login flow as described above. @thchia Could you offer some guidance on how I would implement that?
Hi @Raviteza7796 and @AjaySewradj - sorry for the late response here. To achieve what you want, I think you can do something like this:
// userManager / AppWithAuth setup removed for brevity
<Router>
<Switch>
<Route
path="/callback"
render={routeProps => (
<Callback
onSuccess={user => {
// `user.state` will reflect the state that was passed in via signinArgs.
routeProps.history.push('/route-inside-app')
}}
userManager={userManager}
/>
)}
/>
<Route exact path="/" component={PageWithLoginButton} />
<AppWithAuth />
</Switch>
</Router>
Someone going to yoursite.com will land on the PageWithLoginButton component. Upon clicking the button, you can navigate them to any route defined inside the AppWithAuth (e.g. /route-inside-app). This will trigger the auth flow.