Skip to content

Commit c8455e1

Browse files
committed
style: format misc
1 parent f46c472 commit c8455e1

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

lib/src/middlewares/authorization_middleware.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ Middleware authorizationMiddleware() {
108108
// If user is null here, it means requiresAuthentication was false,
109109
// but specificPermission implies authentication. This is a misconfiguration
110110
// or an attempt to access a protected resource publicly.
111-
if (user == null || !permissionService.hasPermission(user, permission)) {
111+
if (user == null ||
112+
!permissionService.hasPermission(user, permission)) {
112113
throw const ForbiddenException(
113114
'You do not have permission to perform this action.',
114115
);

lib/src/middlewares/ownership_check_middleware.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ Middleware ownershipCheckMiddleware() {
5353
permission = modelConfig.deletePermission;
5454
default:
5555
// For any other methods, no ownership check is performed.
56-
_log.finer('Method "$method" does not require ownership check. Skipping.');
56+
_log.finer(
57+
'Method "$method" does not require ownership check. Skipping.',
58+
);
5759
return handler(context);
5860
}
5961

routes/api/v1/data/_middleware.dart

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ import 'package:flutter_news_app_api_server_full_source_code/src/registry/model_
1111
// Helper middleware for applying rate limiting to the data routes.
1212
Middleware _dataRateLimiterMiddleware() {
1313
return (handler) {
14-
return (context) async { // Made async because ipKeyExtractor is async
14+
return (context) async {
15+
// Made async because ipKeyExtractor is async
1516
final user = context.read<User?>(); // Read nullable User
1617
final permissionService = context.read<PermissionService>();
1718

1819
// Users with the bypass permission are not rate-limited.
19-
if (user != null && permissionService.hasPermission(
20-
user,
21-
Permissions.rateLimitingBypass,
22-
)) {
20+
if (user != null &&
21+
permissionService.hasPermission(
22+
user,
23+
Permissions.rateLimitingBypass,
24+
)) {
2325
return handler(context);
2426
}
2527

@@ -193,5 +195,7 @@ Handler middleware(Handler handler) {
193195
.use(authorizationMiddleware()) // Applied fourth (inner-most)
194196
.use(_dataRateLimiterMiddleware()) // Applied third
195197
.use(_conditionalAuthenticationMiddleware()) // Applied second
196-
.use(_modelValidationAndProviderMiddleware()); // Applied first (outermost)
198+
.use(
199+
_modelValidationAndProviderMiddleware(),
200+
); // Applied first (outermost)
197201
}

routes/api/v1/data/index.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ Future<Response> _handleGet(RequestContext context) async {
7878
// If the model is user-owned and the user is authenticated and not an admin,
7979
// then the operation should be scoped to the authenticated user's ID.
8080
// Otherwise, it's a global operation or an admin bypass.
81-
final userIdForRepoCall = (modelConfig.getOwnerId != null &&
81+
final userIdForRepoCall =
82+
(modelConfig.getOwnerId != null &&
8283
authenticatedUser != null &&
8384
!context.read<PermissionService>().isAdmin(authenticatedUser))
8485
? authenticatedUser.id
@@ -134,7 +135,8 @@ Future<Response> _handlePost(RequestContext context) async {
134135
// If the model is user-owned and the user is authenticated and not an admin,
135136
// then the operation should be scoped to the authenticated user's ID.
136137
// Otherwise, it's a global operation or an admin bypass.
137-
final userIdForRepoCall = (modelConfig.getOwnerId != null &&
138+
final userIdForRepoCall =
139+
(modelConfig.getOwnerId != null &&
138140
authenticatedUser != null &&
139141
!context.read<PermissionService>().isAdmin(authenticatedUser))
140142
? authenticatedUser.id

0 commit comments

Comments
 (0)