Dynamic redirect after login
Closed this issue · 1 comments
Is there a way to have this redirect the user to where they originally intended to go within the portal? It looks like you would normally do this using the state parameter in the Azure login URL, and I do see in the code where it parses that parameter, even looking for the "r" value to recognize that as a redirect URL, but it does not seem to actually do anything with it. I would really like the ability to send users directly to their destination instead of dumping everyone into a hard-coded page.
Upon deeper testing, this appears to actually work as it should. I was trying to bypass things a bit because we don't want our users to have to know to click the "Sign in with Azure" button, but not all of our users are AD users, so we can't simply turn on the auto-redirect option across the board.
My end solution was to:
- Create a new AzureLogin page that has the native login module on it
- Enable the auto-redirect setting
- Hide the native login module on our main login page (so it allows configuring it in DNN as the login page but does not redirect to Azure because it is hidden) and instead use a custom form. If the user enters in a username recognized as an AD user, it redirects to the AzureLogin page, which takes over and auto-redirects to Azure. If not, it uses the non-Azure flow we have always used.
- I also modified the module code so that auto-redirect only happens when the rawUrl contains AzureLogin; this way the redirect will not happen when logged in as an admin who can see the hidden login module but is just trying to make an edit to that page.
Originally, I had been trying to conditionally handle the redirect to Azure myself, building the URL manually; this mostly worked but for some reason broke the redirect after login to whatever page the user was trying to hit prior to login.