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

[BUG] auth provider's check method triggering unwanted refresh with XHR call #6639

Open
sqwxl opened this issue Jan 7, 2025 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@sqwxl
Copy link

sqwxl commented Jan 7, 2025

Describe the bug

Hello Refine dev team,

I have a basic registration form that uses the useRegister hook's mutate function to submit form values.

The problem I'm facing is that when the registration is unsuccessful, the page gets refreshed and the browser is interpreting this as a sign to prompt the user to store/update the new password. This is not the expected behavior when the registration failed because of existing username, for example.

More details. I've tracked down the issue to the invalidateAuthStore function in the useRegister implementation, which is invalidating the "check" query. The refresh only happens if the check implementation includes an awaited XHR (fetch).

I understand the browser behavior is out of your control, but I wonder if the refresh mechanism is intentional? It certainly seems like a bug to me.

Steps To Reproduce

  1. Create a basic refine app with a generic auth provider, including the "example" pages.
  2. In the auth provider create a register method which returns { success: false, redirectTo: undefined }
  3. In the auth provider's check method, add any plain fetch to a server. (The simplest is to start a simple HTTP server locally so that you don't run into CORS issues)
  4. Go to the registration page and try to sign up
  5. The page should refresh, and you will be prompted to save credentials even though the registration failed

Expected behavior

Ideally, the cache invalidation should happen silently and only trigger a refresh if needed. In the case described above, there's no reason to refresh/re-render anything.

Packages

Basic packages included by the npm create refine-app@latest command. v1.12.9 at time of writing.

Additional Context

No response

@sqwxl sqwxl added the bug Something isn't working label Jan 7, 2025
@BatuhanW
Copy link
Member

BatuhanW commented Jan 9, 2025

Hello @sqwxl thanks for the issue. We believe you are right, invalidate should only happen if registration is successful. We are open to contributions for this one.

@BatuhanW BatuhanW added the good first issue Good for newcomers label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants