Closed lloan closed 4 years ago
So it looks like the user is already sent to the dashboard page.
Are we thinking that any more data should be passed to dashboard, or should we create a dynamic path?
I don't think we need a dynamic path as we should have the user id available to fetch user data on mounting/rendering the dashboard.
Also, were there reasons for not using router? Is it hard to setup to work for both client/server rendering?
@Maxbrain0 sounds good.
What would be the benefit of using Router
in our current setup?
@lloan, now that I look at it, I think using router would break our Authentication setup. I think (only think, not certain), that setting document.location.href actually reloads the whole application. This givens the chance for the _app to do its redirect lookup and set the user in the context.
If I just execute a router.push("/dashboard") on a successful post to the user login, user is still null in the Dashboard component because we don't trigger any thing in _app. If I then hit the refresh button, the user is available because the cookie is checked on the authenticate/auth endpoint that is fetched in _app.
The benefit of changing is that we'd only fetch the content of the page (ie, Dashboard) after navigating upon successful login (I will build the app and check the Network activity to see if my theory is correct. I'll build to get rid of any HMR junk).
This will hopefully let us know if we're refetching everything and not just the Dashboard page. I'll compare this data with doing a router.push and making a call to the auth endpoint to fetch the user.
The way to allow router usage would probably be to provide a method on the context to set and clear the user. You could also run a getInitProps on every page to check the user. In reality, since most pages are user dependent, we're probably going to have to fetch the data for the specific user in getInitialProps for each page anyway. We could also add a method on the auth context to set and clear the main user.
Anyhow, I'm new to nextjs, so if I'm way off base, sorry you had to read this. :rofl:
Ok I have a picture of the network activity with the current navigation and using the with router. I clear the network activity, and then login.
Note that all of the CSS and application is reloaded (but thank goodness for caching)
I actually turned caching to be safe
The redirect on login seems to be working still. Don't know if we just close this.
Components that require updating:
Tech to be used:
What is expected behavior: Once the user successfully logs in, they should be taken to their dashboard. Ideally, they should land to the home section of their dashboard, where they have an overview of what is going on.