CovEducation / CovEd

Education assistance during COVID-19 outbreak
https://coved.herokuapp.com/
MIT License
2 stars 1 forks source link

Protected Page redirects to Sign In eventhough User is logged in. #126

Closed sanjayyepuri closed 4 years ago

sanjayyepuri commented 4 years ago

This bug occurs when you navigate to a protected page (Find a Mentor, Profile, or Speaker Series pages) and hit refresh.

This is caused by a race condition that occurs between the firebase-auth callback and the page render. Essentially, the page renders before the User object is updated with the logged in user's state. This causes the ProtectedPage to see undefined and redirect the user to SignIn.

One possible solution is to rather than redirect to the Sign In page, we render the SignIn Component directly in ProtectedPage. Then, when the User object eventually gets updated, the correct page is shown to the user.

oupadhyay commented 4 years ago

Isn't it possible to just redirect to the home page, so that the site updates and so when they try to go to the Find a Mentor, Profile, or Speaker Series pages, the User object will have been updated unless the user has some superhuman reflexes and blazing fast internet?

This is far easier and makes more sense in my opinion than just showing them the same Profile information that they just filled out.

sanjayyepuri commented 4 years ago

The issue is if you are currently on, let's say, the Profile page and hit refresh, you get redirected to the Sign In Page (with your change, the Home Page). The correct behavior, for a logged-in user, would be to stay on the same page.

oupadhyay commented 4 years ago

I am not sure why the correct behavior is to stay on the same page, but regardless, Michael seems to have made changes. I will look over them tomorrow, but if you could as well that would be great.