conduit-full — auth & request flow
verifyToken runs in front of nearly every route, but it's not a
gate — no Authorization header just means the request proceeds
with req.loggedUser left unset. Each controller decides for
itself whether that's acceptable. See
System Architecture for where this
sits in the request chain.
next() immediately — request continues anonymous, no
error
req.loggedUser set from the verified email, request
continues
errorHandler, request stops
GET /api/articles/:slug
Works with or without a token. If one's present, the response's
favorited/following fields reflect the real
logged-in user's state; if not, they're just false. No
UnauthorizedError either way.
POST /api/articles
Same middleware, but the controller itself checks
if (!loggedUser) throw new UnauthorizedError() as its first
line — the gate is in application code, not the middleware.
This exact distinction is what the frontend's
getComments.ts got wrong: the GET-comments route is
soft-auth, so whether a token is sent genuinely changes each comment
author's following/followersCount — but the
service never accepted a headers param at all, unlike its
siblings. Comments were always fetched as if anonymous, even when logged
in. Fixed in the service; see todo.md Phase 58 for the full
trace.