Spaces:
Runtime error
Runtime error
Download TaskTrackingSystem.WebApi/Infrastructure/DataScopeAuthorization.cs from Yuruyuruu/task-tracking-system: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/spaces/Yuruyuruu/task-tracking-system/resolve/main/TaskTrackingSystem.WebApi/Infrastructure/DataScopeAuthorization.cs
- Command line
-
hf download hf://spaces/Yuruyuruu/task-tracking-system/TaskTrackingSystem.WebApi/Infrastructure/DataScopeAuthorization.cs
-
curl -L -o DataScopeAuthorization.cs https://huggingface.co/spaces/Yuruyuruu/task-tracking-system/resolve/main/TaskTrackingSystem.WebApi/Infrastructure/DataScopeAuthorization.cs
1.03 kB
| using Microsoft.EntityFrameworkCore; | |
| using System.Threading.Tasks; | |
| using TaskTrackingSystem.Database.AppDbContextModels; | |
| namespace TaskTrackingSystem.WebApi.Infrastructure | |
| { | |
| public static class DataScopeAuthorization | |
| { | |
| public static async Task<bool> IsAdminScopeAsync(AppDbContext db, long roleId) | |
| { | |
| if (roleId <= 0) return false; | |
| return await db.RolePermissions.AnyAsync(rp => | |
| rp.RoleId == roleId && | |
| !rp.IsDeleted && | |
| rp.Permission.PermissionCode == "Roles_List" && | |
| !rp.Permission.IsDeleted); | |
| } | |
| public static async Task<bool> IsManagerScopeAsync(AppDbContext db, long roleId) | |
| { | |
| if (roleId <= 0) return false; | |
| return await db.RolePermissions.AnyAsync(rp => | |
| rp.RoleId == roleId && | |
| !rp.IsDeleted && | |
| rp.Permission.PermissionCode == "Projects_Create" && | |
| !rp.Permission.IsDeleted); | |
| } | |
| } | |
| } | |