adrianhajdin / project_mern_memories

This is a code repository for the corresponding video tutorial. Using React, Node.js, Express & MongoDB you'll learn how to build a Full Stack MERN Application - from start to finish. The App is called "Memories" and it is a simple social media app that allows users to post interesting events that happened in their lives.
https://youtube.com/playlist?list=PL6QREj8te1P7VSwhrMf3D3Xt4V6_SRkhu
5k stars 1.84k forks source link

Login/Signup Button behaviour #121

Open bharatpaliwal-169 opened 2 years ago

bharatpaliwal-169 commented 2 years ago

BUG When we are there on site for long and then when we logout, without explicitly hard refreshing the page, if we logout then again if we click on the button the page refreshes and lands to /posts instead of going to /auth.

If someone ever came across this and have solved it kindly share the approach. Thanks in advance.

rua02me commented 2 years ago

@bharatpaliwal-169 hi, I just arrived at 4:29:23; have u successfully logged in through google? and also signed up? my page is just still and no error come out T^T

bharatpaliwal-169 commented 2 years ago

Hi @rua02me , No google npm package is depricated and using new react-google-auth package need a lot of efforts , since project is long i suggest to skip this and continue forward

AlexanderSChen commented 1 year ago

In your client App.js file make this change to stop the sign in button from redirecting to /posts and make sure it only redirects to /auth. Hope this helps! component={() => (!user ? <Auth /> : <Redirect to="/posts" />)} /> ==> <Route path="/auth" exact component={Auth} /> The problem for me was I used the google sign in and set the user in localStorage but did not use googleLogout so localStorage thinks a user is still logged in and constantly redirects the sign in button to /posts.