-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
Navigation trade off #12402
Comments
@AmitMY We wrap ion-nav in a <div *ngIf="!hideHomePage"> We do not set the rootPage until we verify if the user is logged in or not. If logged in we set the rootPage to their homepage and set hideHomePage = false. This means that the logic to render the page is not called until we know the state of the user. |
Not sure what issue you faced, as you come on empty when I filter issues I did the same idea, setting It is quite similar to #11459 |
Is this a website or a mobile app? My current app works as such. Are you trying to do something similar? Logged in user Non Logged in user www.test.com -> if no user token stay on page. CSR view |
Both. |
I have an auth class as follows
|
The interesting part here for me is |
I have a whole lot of custom logic to manage navigation between pages atm. I have a custom directive that allows navigation. As well as logic to use the serializer to get the component the current page is on. The I have the ability to setRoot and handle failures in that utility. At the moment it has error cases custom for our app that handles some odd cases due to the serializer. Let me see if I can get a slimmed down version for you. I also have analytics tracking in the utility. |
I guess what you care about is this line
If there is an issue navigating to a page we set the after generic login page as the last page we tried to navigate to. Else we set it to null so that we set the last page as the current page we are on per the browser. |
Hi, this is exactly my opinion. @ztecharoberts solutions is nice, and something we already tried or at least something similar. But there is something I'm not sure about: I think implementing a classical solution of Guards with the possibility to have multiple states and redirect user, would much more power, is much more readable code and more flexible. In the past, redirecting roots on guards was available but removed on 3.5.x. So the rooter how is it know (working good) with the ability to redirect pages would be most of the things we all need. The good news are, Dan wrote to work on it soon, I hope we can test and give feedback in a few days. Thx to all |
all of our pages show a loading spinner until accounts are ready.
|
Okay, but there are could be code in IonDidEnter and others, so there should also be no code in it. Right? |
The idea is our pages contain little to no code in them. We have a lot of our logic based in components. If the component is not rendered none of our code is executed. |
Thanks for the issue! This issue is being closed due to inactivity. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. Thank you for using Ionic! |
Ionic version: (check one with "x")
[ ] 1.x (For Ionic 1.x issues, please use https://github.com/ionic-team/ionic-v1)
[ ] 2.x
[x] 3.x
I'm submitting a ... (check one with "x")
[ ] bug report
[x] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/
Current behavior:
Having an app with navigation guards (
ionViewCanEnter
), and URL segments, does not allow a fallback for page evaluation.Having an app with authentication, lets say I have 3 pages:
If I don't set
rootPage
, nothing happens by default, so I have to set it, and the only choice islogin
Now if I go to
/home
, I see a blank page, because it tried to load thehome
page, but the user is not authenticated. User must go to either/
or/login
.After the user is authenticated, now when he goes to
/home
, everything is fine, but if by accident he pressed on a link of/login
, there is a blank page (can't enter, so nothing)Finally, one would say: Check if the user is authenticated. if they are, set
rootPage
tohome
, and if not tologin
.But what if the user (authenticated) goes to
/other
? they are immediately redirected tohome
. A possible suggestion would be to check the active page, but because of the nav guard, there is no active page before we know if the user is authenticated, so must also add a timeout for it to happen asyncronically.Note: this does not happen only with authentication, even with sequential nav guards, like checking if page got all parameters.
Expected behavior:
I think there should be an option to bind a function to the nav, like
onCantEnter
or something, that fires only if the first page it tries to load can not be entered. It would get the component it tried to load, and let the user do whatever with that information, for example:Note: I din't find where in the code it does that first load and executes
ionViewCanEnter
, so I can't create a PR.Ionic info: (run
ionic info
from a terminal/cmd prompt and paste output below):The text was updated successfully, but these errors were encountered: