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

Protect User Routes #67

Open
2 tasks
sanjaysah101 opened this issue Sep 19, 2024 · 0 comments
Open
2 tasks

Protect User Routes #67

sanjaysah101 opened this issue Sep 19, 2024 · 0 comments
Labels
ansopedia enhancement New feature or request good first issue Good for newcomers hacktoberfest

Comments

@sanjaysah101
Copy link
Collaborator

Description:

Implement access control for user-related routes to ensure only authenticated users can access them. Specifically, the following routes need to be protected:

  • GET /users
  • GET /users/:username

Key Requirements:

  1. Authentication Middleware:

    • Use the validateAccessToken middleware to ensure only logged-in users can access these routes.
  2. Route Protection:

    • Apply the middleware to the following routes:
      router.get('/users', validateAccessToken, getAllUsers);
      router.get('/users/:username', validateAccessToken, getUserByUsername);
  3. Testing:

    • Write unit tests to cover the following scenarios:
      • Verify that authenticated users can access both routes successfully.
      • Ensure that unauthenticated users receive a 401 Unauthorized response when trying to access these routes.

Tasks:

  • Apply the validateAccessToken middleware to the /users and /users/:username routes.
  • Write unit tests for all scenarios mentioned above.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ansopedia enhancement New feature or request good first issue Good for newcomers hacktoberfest
Projects
None yet
Development

No branches or pull requests

1 participant