# Who May Do What

Signing in says who someone is; authorization says what they may do. Require a signed-in user with middleware, tell 401 from 403, give users roles, check that people change only their own things, and test every rule.

Updated: November 19, 2026

## [Requiring a Signed-In User](https://www.ask-codey.com/courses/nodejs-in-depth/topics/node-auth-requiring-sign-in)

1. [Requiring a Signed-In User](https://www.ask-codey.com/lessons/node-auth-require-user-middleware) (Journeyman): A requireUser middleware checks the token in a request's Authorization header before the route runs, puts the signed-in user in req.user, and answers 401 when the token is missing, made up or expired.

## [Roles and Ownership](https://www.ask-codey.com/courses/nodejs-in-depth/topics/node-auth-roles)

1. [Roles and Ownership: 401 or 403](https://www.ask-codey.com/lessons/node-auth-roles-and-ownership) (Journeyman): Signed in isn't the same as allowed, so a requireRole middleware lets only the right role through, an ownership check compares a record's owner with req.user.id, and both refuse with 403, while 401 stays for a request with no valid token.

## [Exercise: Team Task Board](https://www.ask-codey.com/courses/nodejs-in-depth/topics/exercise-node-team-task-board)

1. [Exercise: Team Task Board](https://www.ask-codey.com/lessons/exercise-node-team-task-board) (Journeyman): Finish Crew Board's task API with a requireUser and a requireRole middleware and an ownership check, so anyone signed in reads the board, members change only their own tasks and only an admin deletes, and let Supertest's tests check every rule as each kind of user.

Source: https://www.ask-codey.com/courses/nodejs-in-depth/chapters/node-who-may-do-what
