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 Fix: fetch logic to display users #498

Merged
merged 1 commit into from
Jul 17, 2024

Conversation

IsaacJrTypes
Copy link
Contributor

@IsaacJrTypes IsaacJrTypes commented Jul 17, 2024

Resolves #471

This PR updates the user fetch logic with the user's JW token. In our backend, we updated our get all users endpoint to require the admin role in the user's JW Token. This restriction prevented the edit user role page from fetching all users from database.

The commit includes the ability to disable strict mode in the next.config.js file. Using useEffect to trigger a fetch call in strict mode causes the fetch request to fire twice. After further investigation, I found that strict mode is enabled by default in next.js. I included it as a quick way to disable strict mode when testing API endpoints using the front-end.

How to test

  • run front-end and back-end, login using a user with admin privileges, click My Account under the user icon, then click Edit user

Note: Double check the back-end listener is set to 3000 since front-end expects the backend port to be set at 3000.

Results:
CleanShot 2024-07-16 at 21 02 14@2x

@IsaacJrTypes IsaacJrTypes added bug Something isn't working Sprint 9 labels Jul 17, 2024
@IsaacJrTypes IsaacJrTypes requested review from intisarosman1 and a team July 17, 2024 04:51
@IsaacJrTypes IsaacJrTypes self-assigned this Jul 17, 2024
@IsaacJrTypes IsaacJrTypes requested review from bcko, cshimm, keiffer213, heosman, brinkbrink and taylorpapke and removed request for a team July 17, 2024 04:51
@IsaacJrTypes IsaacJrTypes enabled auto-merge (squash) July 17, 2024 04:52
Copy link
Contributor

@intisarosman1 intisarosman1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The users now all display on the page and I am able to successfully change their user roles.
Screenshot 2024-07-16 232507

Copy link
Contributor

@heosman heosman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The users are now loaded on the Edit User Role page and I no longer get an Unauthorized error.

image

@IsaacJrTypes IsaacJrTypes merged commit 866f2e0 into main Jul 17, 2024
7 checks passed
@heosman heosman deleted the belindasNextjs-bug-9-471-edit-user-role-page-1 branch July 17, 2024 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Sprint 9
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Edit-User-Role-Page: Fix logic to display users
3 participants