Closed AndreSteenbergen closed 6 years ago
If I recall correctly, this is already possible.
Turns out that this is not already possible but is easy for me to add.
I will add this feature once finishing the unit-tests.
Thanks, a redirect will certainly be more user friendly in the url. Is it also possible to have a redirect parameter as well? I mean, something like usermanager.loginRedirect({redirectAfterLogin: "mysteriousPage?howdidIgethere"}), but I guess that will be harder ...
I looked at this today, and it appears already to be working with this configuration:
export default {
loginRedirectModuleId: "private",
logoutRedirectModuleId: "index",
}
https://github.com/shaunluttin/aurelia-open-id-connect-demos has an auth0 demo that does that. Does that properly capture the requirements?
If the above captures the initial requirements, let me know, and I can also consider opening an issue for the redirect parameters(s).
Thanks, will try it tomorrow at work
I am doing that right now, but it sticks with to redirected url with the entire hash. The hash part is what I am trying to avoid, because I have 1 requirement to show as clean urls as possible. That's why I am adding a an url into the history stack, so the hash-fragment is removed from the address bar history.pushState({}, "Welcome back", "");
This feature request was more a "don't load the module, but redirect to the module".
I have the following in my configuration:
export default {
redirect_route: redirect_route,
loginRedirectModuleId : "modules/dashboard",
logoutRedirectModuleId: "modules/dashboard",
userManagerSettings : config
};
I guess this does the loading (from the source (open-id-connect-navigation-strategies.ts
))
it tells the navigationInstruction which module to load. I would like to perform a redirect instead. That isn't possible at this moment right?
public async signInRedirectCallback(instruction: NavigationInstruction): Promise<any> {
const callbackHandler = async () => {
const args: any = {};
return this.userManager.signinRedirectCallback(args);
};
const postCallbackRedirect = () => {
instruction.config.moduleId =
this.openIdConnectConfiguration.loginRedirectModuleId;
};
return this.runHandlerAndAlwaysRedirect(callbackHandler, postCallbackRedirect);
}
Hmm. I understand now. You clarified with the "don't load the module, redirect to the module" comment. That makes sense, and I think it runs into the limits of how well I understand Aurelia's router. I'll take a look at how to redirect instead of to load. If you know how to do that, please let me know (or create a PR), and I will implement it ASAP.
I will try and see what I can do, I am probably working on our front end application tomorrow. Don't see why I can't make an extra adjustment, in this bridge.
We played with this for about 30-minutes this afternoon.
This is the original code:
const postCallbackRedirect = () => {
instruction.config.moduleId =
this.openIdConnectConfiguration.loginRedirectModuleId;
};
Filling the redirect requirement is as easy as this:
const postCallbackRedirect = () => {
instruction.config.redirect =
this.openIdConnectConfiguration.loginRedirectModuleId;
};
Fixed with 11ea315a8ff741c670e1f33cd332a397aa87efbc
Let me know if that change works for you. I prefer the redirect too. Thank you for the suggestion. :-)
The art of time zones ;) Yes that will work, just one method change wow... Have you placed this in the npm package, or should I build from source?
It's in the NPM package. 👍
After successful login/ logout, it might be nicer to redirect the user to the module designated in the configuration. Just a nice to have, or is it already possible?