Skip to content
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

Persist authentication issue #1

Open
chaoming opened this issue Oct 2, 2019 · 6 comments
Open

Persist authentication issue #1

chaoming opened this issue Oct 2, 2019 · 6 comments

Comments

@chaoming
Copy link

chaoming commented Oct 2, 2019

I implemented this into my application but it seems that the code to detect if currentUser exists

        !!currentUser ? (
          <RouteComponent {...routeProps} />
        ) : (
          <Redirect to={"/login"} />
        )

is executed before loading the currentUser

  useEffect(() => {
    app.auth().onAuthStateChanged(setCurrentUser);
  }, []);

so the result is the user will be redirected to login after refreshing the page.

@m-zaremba
Copy link

Did you find solution for this?

@wengzilla
Copy link

I am also generally having flicker issues whereby the user is not loaded fast enough. What's the best way to block rendering until currentUser has been loaded?

@MrBlue9
Copy link

MrBlue9 commented Nov 22, 2019

Having the same issue. Accessing a private route redirects to the login page which in turn redirects to '/' because at that point currentUser is finally available.

@csulit
Copy link

csulit commented Jan 10, 2020

Having the same issue when successfully login but when the page reloads login form flickers.

@csulit
Copy link

csulit commented Jan 11, 2020

I implemented this into my application but it seems that the code to detect if currentUser exists

        !!currentUser ? (
          <RouteComponent {...routeProps} />
        ) : (
          <Redirect to={"/login"} />
        )

is executed before loading the currentUser

  useEffect(() => {
    app.auth().onAuthStateChanged(setCurrentUser);
  }, []);

so the result is the user will be redirected to login after refreshing the page.

Can you share your changes? :)

@Nomzy-kush
Copy link

I keep encountering this error 'TypeError: firebase_js__WEBPACK_IMPORTED_MODULE_1_.default.auth is not a function' in my Auth.js please help.

farhanatfunkarahdotpk added a commit to farhanatfunkarahdotpk/firebase that referenced this issue Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants