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

Added an API that fetches all the admins #1774

Open
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

ntrehan
Copy link
Member

@ntrehan ntrehan commented Oct 8, 2024

Fixes #1770

What changes did you make and why did you make them ?

  • Added a API that fetches all the users that are Admins

@vorleakyek
Copy link
Member

@ntrehan, if possible can you provide some info on how to test this in the backend? Thanks!

@ntrehan
Copy link
Member Author

ntrehan commented Oct 28, 2024

@ntrehan, if possible can you provide some info on how to test this in the backend? Thanks!

Hey @vorleakyek
Thanks for your comment and testing out the PR!
Sure
Let me guide you through the whole process

Step 1. Building the API address
The new api has been added in users.router.js, and if you look at the comment at the top
It says that the base url is /api/users

That means that to hit our specific api we will have to call
"server-url"/api/users/admins
here "server-url" is the name of our node server
which when building locally is usually http://localhost:3000

So the end point for the API would become
http://localhost:3000/api/users/admins

Step 2: Getting authenticated
Now that our API endpoint is ready
Please make sure you have the ''x-customrequired-header" set in your request
It is a security header generated on signin to authenticate the admin for every request

To get the value of this header

  1. login to your admin account in VRMS
  2. Open the network tab in chrome/other browser of your choice
  3. Click on any tab - users/projects etc.
  4. when clicking on those tabs you will see that there is a corresponding request in the network tab
    image
  5. On this request, get the "x-customrequired-header" value in the headers
    image

Copy this value and add to the headers in the request

Your Request would become
curl --location 'http://localhost:3000/api/users/admins'
--header 'x-customrequired-header: custom-header-here'

Please not that you would need to replace custom-header-here with your own header you find from the other request
Please feel free to reach out if you have any more questions

@JackHaeg JackHaeg added the time-sensitive should be solved as soon as possible label Oct 29, 2024
@vorleakyek
Copy link
Member

@ntrehan, thanks for the details testing information. It's very helpful!
The code looks good, and it seems like the return data have one "superadmin" and the rest are "admin" for the accessLevel.
Thanks for working on it.

@vorleakyek vorleakyek added the ready for dev lead Add to issue when dev lead needs to take some action label Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for dev lead Add to issue when dev lead needs to take some action time-sensitive should be solved as soon as possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create API call to get all users who are listed as VRMS Admins
3 participants