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

API requests happen before auth check is complete. #149

Closed
mstone121 opened this issue Oct 24, 2022 · 0 comments · Fixed by #170
Closed

API requests happen before auth check is complete. #149

mstone121 opened this issue Oct 24, 2022 · 0 comments · Fixed by #170
Assignees
Labels
bug Something isn't working Task 3.6 Front-end implementation

Comments

@mstone121
Copy link
Contributor

Overview

API requests are being sent before authentication checks complete.

This is important for two reasons:

  • We don't want to show data to users who shouldn't see it.
  • We want the correct data to load for each user. The auth check returns info about the user which determines what shows up on the page.

This is probably because the RTK query hooks used in components to make API requests are fired as soon as they are mounted. Rather than trying to tell each component to wait until auth, we should probably make it so these components don't mount until the auth check completes. Implementing this could also resolve #78.

Expected Behavior

API requests should be sent after auth checks.

Actual Behavior

API requests happen are being sent before auth checks.

Steps to Reproduce

Note: These steps assume #148 has been merged.

  • Login as a c1@example.com
  • Go to the submissions page
  • Open the network tab
  • Refresh the page from the browser
  • Notice the request to /api/boundaries with no query parameters
  • Select a different utility
  • Notice the request to /api/boundaries/?utilities=<selected utility id>
  • Select the original utility
  • Notice the request to api/boundaries/?utilities=<original utility id>

Demo

Screen.Recording.2022-10-24.at.9.10.42.AM.mov
@mstone121 mstone121 added the bug Something isn't working label Oct 24, 2022
@rajadain rajadain added the Task 3.6 Front-end implementation label Oct 27, 2022
@mstone121 mstone121 self-assigned this Oct 28, 2022
@mstone121 mstone121 mentioned this issue Oct 28, 2022
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Task 3.6 Front-end implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants