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
Routing: Query parameters for CanLoad guard not available #12411
Comments
that's not true. |
i use official sample http://run.plnkr.co/6XSNCCpgbS1BzqtW/ from tutorial at https://angular.io/docs/ts/latest/guide/router.html. |
@adoris we cannot provide an ActivatedRoute to a canLoad guard because CanLoad guards haven't been constructed at this point. What we can provide instead is a UrlTree. |
I face this same problem and have no idea what alternative there is. |
CanLoad now defines UrlSegment[] as a second parameter of the function. Users can store the initial url segments and refer to them later, e.g. to go back to the original url after authentication via router.navigate(urlSegments). Existing code still works as before because the second function parameter does not have to be defined. Closes angular#12411
I submitted a pull request which adds url segments to the CanLoad interface. The ActivatedRouteSnapshot is unfortunately not available at this stage in the routing call, but the url segment array should be fine for common usage, e.g. |
CanLoad now defines UrlSegment[] as a second parameter of the function. Users can store the initial url segments and refer to them later, e.g. to go back to the original url after authentication via router.navigate(urlSegments). Existing code still works as before because the second function parameter does not have to be defined. Closes angular#12411
@marcuskrahl what's the status of this? I see the PR was never merged |
@fbobbio unfortunately no response from the angular devs. I might update the pull request and ping the devs again soon. |
Hi I've just run into this problem... I want to store the current url, so that I can redirect to it after a successful login. For now I'm relying on canActivate.. which means sometimes a lazy module is loaded unnecessarily.. which isn't ideal. @marcuskrahl Do you know which angular dev to ping for router PRs ? |
I want to do this too, so let's hope this move on |
I think i am also having a problem here.... user is on a view where they are not authenticated, no token , anon user. the module has a "CanLoad" that can see they are not logged in and redir the user to get a token. |
a note on this: something know that the app is trying to navigate the user to a module, so the router.Navigate call has the target route and had to figure out that it went to a route that needed a module load. |
i feel that this is a core flaw in the router / lazy load and needs to be at a more urgent priority. the sts handles the user login UI and this keeps the app from knowing the users password, this is also used to allow for sign on with Facebook, Google, Twitter and Microsoft accounts via OIDC / OAuth 2 so not having some kind of router state (whatever the details may be) that we can pass to the sts makes can load non usable for users of this type of login method to get a user token. the workaround of using can activate means that modules do not lazyload based on security rules. the basic library for using identity server with angular is https://github.com/IdentityModel/oidc-client-js and it works with can activate perfectly in my app. i pass a state object on calling for a token and it returns it on the return trip, i can then make a navigate call to the router to get back to the url the user was trying to go to at the start. if we need a different kind of state object that can be done, just need a definition to work with. |
CanLoad now defines UrlSegment[] as a second parameter of the function. Users can store the initial url segments and refer to them later, e.g. to go back to the original url after authentication via router.navigate(urlSegments). Existing code still works as before because the second function parameter does not have to be defined. Closes angular#12411
CanLoad now defines UrlSegment[] as a second parameter of the function. Users can store the initial url segments and refer to them later, e.g. to go back to the original url after authentication via router.navigate(urlSegments). Existing code still works as before because the second function parameter does not have to be defined. Closes angular#12411
CanLoad now defines UrlSegment[] as a second parameter of the function. Users can store the initial url segments and refer to them later, e.g. to go back to the original url after authentication via router.navigate(urlSegments). Existing code still works as before because the second function parameter does not have to be defined. Closes angular#12411
CanLoad now defines UrlSegment[] as a second parameter of the function. Users can store the initial url segments and refer to them later, e.g. to go back to the original url after authentication via router.navigate(urlSegments). Existing code still works as before because the second function parameter does not have to be defined. Closes angular#12411
CanLoad now defines UrlSegment[] as a second parameter of the function. Users can store the initial url segments and refer to them later, e.g. to go back to the original url after authentication via router.navigate(urlSegments). Existing code still works as before because the second function parameter does not have to be defined. Closes angular#12411
CanLoad now defines UrlSegment[] as a second parameter of the function. Users can store the initial url segments and refer to them later, e.g. to go back to the original url after authentication via router.navigate(urlSegments). Existing code still works as before because the second function parameter does not have to be defined. Closes angular#12411
CanLoad now defines UrlSegment[] as a second parameter of the function. Users can store the initial url segments and refer to them later, e.g. to go back to the original url after authentication via router.navigate(urlSegments). Existing code still works as before because the second function parameter does not have to be defined. Closes angular#12411
CanLoad now defines UrlSegment[] as a second parameter of the function. Users can store the initial url segments and refer to them later, e.g. to go back to the original url after authentication via router.navigate(urlSegments). Existing code still works as before because the second function parameter does not have to be defined. Closes angular#12411
CanLoad now defines UrlSegment[] as a second parameter of the function. Users can store the initial url segments and refer to them later, e.g. to go back to the original url after authentication via router.navigate(urlSegments). Existing code still works as before because the second function parameter does not have to be defined. Closes angular#12411
CanLoad now defines UrlSegment[] as a second parameter of the function. Users can store the initial url segments and refer to them later, e.g. to go back to the original url after authentication via router.navigate(urlSegments). Existing code still works as before because the second function parameter does not have to be defined. Closes angular#12411
CanLoad now defines UrlSegment[] as a second parameter of the function. Users can store the initial url segments and refer to them later, e.g. to go back to the original url after authentication via router.navigate(urlSegments). Existing code still works as before because the second function parameter does not have to be defined. Closes angular#12411
CanLoad now defines UrlSegment[] as a second parameter of the function. Users can store the initial url segments and refer to them later, e.g. to go back to the original url after authentication via router.navigate(urlSegments). Existing code still works as before because the second function parameter does not have to be defined. Closes angular#12411
CanLoad now defines UrlSegment[] as a second parameter of the function. Users can store the initial url segments and refer to them later, e.g. to go back to the original url after authentication via router.navigate(urlSegments). Existing code still works as before because the second function parameter does not have to be defined. Closes angular#12411
CanLoad now defines UrlSegment[] as a second parameter of the function. Users can store the initial url segments and refer to them later, e.g. to go back to the original url after authentication via router.navigate(urlSegments). Existing code still works as before because the second function parameter does not have to be defined. Closes angular#12411
CanLoad now defines UrlSegment[] as a second parameter of the function. Users can store the initial url segments and refer to them later, e.g. to go back to the original url after authentication via router.navigate(urlSegments). Existing code still works as before because the second function parameter does not have to be defined. Closes angular#12411
CanLoad now defines UrlSegment[] as a second parameter of the function. Users can store the initial url segments and refer to them later, e.g. to go back to the original url after authentication via router.navigate(urlSegments). Existing code still works as before because the second function parameter does not have to be defined. Closes angular#12411
CanLoad now defines UrlSegment[] as a second parameter of the function. Users can store the initial url segments and refer to them later, e.g. to go back to the original url after authentication via router.navigate(urlSegments). Existing code still works as before because the second function parameter does not have to be defined. Closes angular#12411
CanLoad now defines UrlSegment[] as a second parameter of the function. Users can store the initial url segments and refer to them later, e.g. to go back to the original url after authentication via router.navigate(urlSegments). Existing code still works as before because the second function parameter does not have to be defined. Closes angular#12411
We also have a requirement where this stops us. We want to send URLs in emails. When user clicks a link and their browser loads the angular app, with a url to a lazy loaded module, there is no way to navigate to Login with a return Url from CanLoad if CanLoad fails the authentication check. In addition to this, lazy modules can get loaded even when the user is not authenticated. CanActivate in the lazy routes still boots them back to Login, but I strongly believe that CanLoad needs the same or similar args as CanActivate. |
Would also love to see this solved. |
CanLoad now defines UrlSegment[] as a second parameter of the function. Users can store the initial url segments and refer to them later, e.g. to go back to the original url after authentication via router.navigate(urlSegments). Existing code still works as before because the second function parameter does not have to be defined. Closes angular#12411
CanLoad now defines UrlSegment[] as a second parameter of the function. Users can store the initial url segments and refer to them later, e.g. to go back to the original url after authentication via router.navigate(urlSegments). Existing code still works as before because the second function parameter does not have to be defined. Closes angular#12411
CanLoad now defines UrlSegment[] as a second parameter of the function. Users can store the initial url segments and refer to them later, e.g. to go back to the original url after authentication via router.navigate(urlSegments). Existing code still works as before because the second function parameter does not have to be defined. Closes angular#12411
Any idea when the PR will be merged? |
I am waiting for the merge too, or at least this issue to get to a final point. |
Need this to store the redirect url after login. |
My "temporary" workaround is saving the URL as follows:
When auth end point calls back, I run the following code:
Hope RouterStateSnapshot is added soon to CanLoad in @angular/router |
@RGVGreatCoder the problem with this solution is that your canLoad now depends on |
CanLoad now defines UrlSegment[] as a second parameter of the function. Users can store the initial url segments and refer to them later, e.g. to go back to the original url after authentication via router.navigate(urlSegments). Existing code still works as before because the second function parameter does not have to be defined. Closes angular#12411 PR Close angular#13127
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a ... (check one with "x")
Current behavior
I try to implement simple app with silent login via auth token (sessionId). If no sessionId provided- fallback to login via username/password.
If i try to navigate to component from synchronously loaded module - in can be protected with CanActivate guard - we have ActivatedRouteSnapshot with query parameters. If i try to navigate to a lazily loaded component - it is prtoected with CanLoad guard.
CanLoad guard has no access query parameter (?&) or parameter in matrix notation(;) from browser address string - has no ActivatedRouteSnapshot parameter.
Expected behavior
i expect, that query parameters (or matrix notation parameters) are available in CanLoad guard via ActivatedRoute parameter.
Minimal reproduction of the problem with instructions
http://plnkr.co has no possibility to use many html pages -> i have prepared modified sample of heroes app from tutorial https://angular.io/docs/ts/latest/guide/router.html.
Modified sample can be found at https://github.com/adoris/tour-of-heroes
All other links must be processed without login page, but login page displayed.
If I call app with this links from my sample app - i want to proceed without login-screen:
http://localhost:4200/hero/13?SessionId=98765&Extras1=testextras
http://localhost:4200/heroes;id=13;SessionId=98765;Extras1=testextras
Please tell us about your environment:
angular-cli, windows, vs code.
The text was updated successfully, but these errors were encountered: