@@ -4,6 +4,7 @@ import 'package:core/core.dart';
4
4
import 'package:dart_frog/dart_frog.dart' ;
5
5
import 'package:data_repository/data_repository.dart' ;
6
6
import 'package:flutter_news_app_api_server_full_source_code/src/helpers/response_helper.dart' ;
7
+ import 'package:flutter_news_app_api_server_full_source_code/src/middlewares/ownership_check_middleware.dart' ;
7
8
import 'package:flutter_news_app_api_server_full_source_code/src/rbac/permission_service.dart' ;
8
9
import 'package:flutter_news_app_api_server_full_source_code/src/registry/model_registry.dart' ;
9
10
import 'package:flutter_news_app_api_server_full_source_code/src/services/dashboard_summary_service.dart' ;
@@ -330,13 +331,11 @@ Future<Response> _handlePut(
330
331
// simply save the entire request body. Instead, we perform a safe,
331
332
// partial update.
332
333
333
- // 1. Fetch the existing, trusted user object from the database.
334
+ // 1. The existing, trusted user object is already fetched by the
335
+ // `ownershipCheckMiddleware` to prevent duplicate database calls.
334
336
// This ensures we have the current, authoritative state of the user,
335
- // including their correct roles and ID.
336
- final existingUser = await repo.read (
337
- id: id,
338
- userId: userIdForRepoCall,
339
- );
337
+ // including their correct roles and ID, without hitting the DB again.
338
+ final existingUser = context.read <FetchedItem <dynamic >>().data as User ;
340
339
341
340
// 2. Create a new User object by merging only the allowed, safe-to-update
342
341
// fields from the incoming request (`itemToUpdate`) into the
0 commit comments