@@ -266,25 +266,12 @@ Handler middleware(Handler handler) {
266266 ),
267267 ) // Used by AuthService
268268
269- // --- 4. Authentication Middleware (User Context Population) ---
270- // PURPOSE: Reads the `Authorization: Bearer <token>` header, validates
271- // the token using `AuthTokenService`, and provides the
272- // resulting `User?` object into the context.
273- // ORDER: Empirically found to work best in this position.
274- // While it reads `AuthTokenService` (provided in the next step),
275- // this order is critical for correct runtime behavior. The
276- // `AuthTokenService` instance is created before the chain and
277- // captured by its provider closure. Should come BEFORE any
278- // route handlers that need `context.read<User?>()`.
279- .use (authenticationProvider ())
280-
281- // --- 5. Authentication Service Providers (Auth Logic Dependencies) ---
269+ // --- 4. Authentication Service Providers (Auth Logic Dependencies) ---
282270 // PURPOSE: Provide the core services needed for authentication logic.
283- // ORDER: These MUST be provided BEFORE any route handlers that perform
284- // authentication/authorization.
271+ // ORDER: These MUST be provided BEFORE `authenticationProvider` and
272+ // any route handlers that perform authentication/authorization.
285273 // - `Uuid` is used by `AuthService` and `JwtAuthTokenService`.
286- // - `AuthTokenService` is used by `AuthService` and read by
287- // `authenticationProvider` (previous step).
274+ // - `AuthTokenService` is read by `authenticationProvider`.
288275 // - `AuthService` uses several repositories and `AuthTokenService`.
289276 // - `VerificationCodeStorageService` is used by `AuthService`.
290277 // - `TokenBlacklistService` is used by `JwtAuthTokenService`.
@@ -310,7 +297,7 @@ Handler middleware(Handler handler) {
310297 ),
311298 ) // Reads other services/repos
312299
313- // --- 6 . Request Logger (Logging) ---
300+ // --- 5 . Request Logger (Logging) ---
314301 // PURPOSE: Logs details about the incoming request and outgoing response.
315302 // ORDER: Often placed late in the request phase / early in the response
316303 // phase. Placing it here logs the request *before* the handler
0 commit comments