sac-tech-org / job-board

Job board for local Sacramento companies and startups
https://jobs.sac-tech.com
1 stars 0 forks source link

API endpoint authorization #13

Closed rusher2004 closed 4 months ago

rusher2004 commented 4 months ago

Currently, API routes validate the sessions in requests using the withUserSession middleware. This ensures authentication, but we are still lacking authorization for some requests.

For instance, a request to GET /user/me should only allow the user with that username to successfully get a response. To achieve that, we can:

  1. use the id we pull from the session info in the withUserSession and query the db for the related username.
  2. On successful match, continue the request
  3. If not, return a 401 status