There's a screen only logged-in users may use. Each request carries its token in the Authorization header as "Bearer <token>". Our auth guard has to pull the user out of that token and pass it along to the next step. Complete JwtAuthGuard.verify(token). The token is three pieces split by dots (.), and the middle piece holds the user info as { userId, role }. Pull userId and role out of it and return them; the guard then puts that onto req.user. The secret key lives in the environment variable JWT_SECRET. Note: if the token is missing or not in Bearer form, it's already blocked with a 401 (that part is higher up in the guard). Issuing (login), expiry, and refresh are out of scope for this task.
This challenge has you complete a NestJS auth guard. It pulls user info (userId, role) out of a token that arrives as "Bearer <token>" in the Authorization header, puts it on req.user, and blocks the request with a 401 when the token is missing. It uses no token library — only Node's built-in tools — and reads the secret key from the environment variable JWT_SECRET.
This problem is about "how far can you trust a token that came from outside." A token is a value the user carries in themselves, so if you trust its contents as-is you have no way to know who altered them. When verifying code like this, don't only check "does a valid token pass" — make a habit of checking "does a token with altered contents pass too." The real test is the moment a token that should not pass does.