Skip to content

isLoggedIn flag is false after token is refreshed #188

@Bernardo-ive

Description

@Bernardo-ive

isLoggedIn becomes false instead of triggering token refresh when access token expires

Description

When using @fusionauth/react-sdk with shouldAutoRefresh: true, the isLoggedIn flag from useFusionAuth() becomes false after the access token expires, even though a valid refreshToken is present.

Expected behavior is that the SDK attempts a token refresh and keeps isLoggedIn === true while the refresh token is still valid.

This was reproduced using the official React quickstart:

https://fusionauth.io/docs/quickstarts/react
might be related to issues #166 #157 #82 which are closed but issue is still present.
there are also mentions that the issue was fixed in 2.4.1 and back in 2.4.2 #157 (comment)

const fusionAuthProviderConfig: FusionAuthProviderConfig = {
  redirectUri: "http://localhost:3000",
  postLogoutRedirectUri: "http://localhost:3000",
  shouldAutoRefresh: true,
  shouldAutoFetchUserInfo: true,
  scope: "openid email profile offline_access",
  clientId: "e9fdb985-9173-4e01-9d73-ac2d60d1dc8e",
  serverUrl: "http://localhost:9011",
  onRedirect: () => {
    console.log("Login successful");
  },
};

Expected behavior

While the refresh token is still valid:

  • The SDK should automatically call the refresh token endpoint.
  • Tokens should be updated.
  • isLoggedIn should remain true.

Actual behavior

  • isLoggedIn switches to false once the access token expires.
  • No refresh request appears to be made, despite shouldAutoRefresh: true.

Affects package

@fusionauth/react-sdk

Affects versions

2.5.1

Steps to reproduce

run the app and FA server (docker in my case)
const { isLoggedIn } = useFusionAuth();
console.log({ isLoggedIn });
wait for token to expire, I put the JWT expire time to 30 seconds on Fusionauth dashboard

Expected behavior

isLoggedIn should be true while refreshToken is not expired, sdk should call the refresh endpoint and update token

Platform

(Please complete the following information)

  • Device: desktop mac
  • OS: macOS
  • Browser Version 144.0.7559.97 (Official Build) (arm64)
  • Database PostgresSQL

Community guidelines

All issues filed in this repository must abide by the FusionAuth community guidelines.

Additional context

I’ve also encountered this behavior in a application using FusionAuth that i'm developing, not just the quickstart.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions