Moved share permission parsing to jsonb implementation of ef core. Improved auth handling for shares

This commit is contained in:
2025-06-06 14:15:32 +02:00
parent 1ec4450040
commit cfed1aefde
12 changed files with 176 additions and 70 deletions

View File

@@ -68,9 +68,14 @@ public class PowerController : Controller
if (server == null)
throw new HttpApiException("No server with this id found", 404);
if (!await AuthorizeService.Authorize(User, server, permission => permission is { Name: "power", Type: ServerPermissionType.ReadWrite }))
throw new HttpApiException("No server with this id found", 404);
var authorizeResult = await AuthorizeService.Authorize(
User, server,
permission => permission.Name == "power" && permission.Type >= ServerPermissionType.ReadWrite
);
if (!authorizeResult.Succeeded)
throw new HttpApiException("No permission for the requested resource", 403);
return server;
}
}