Skip to content

Commit

Permalink
fix: add more roles to sector permission
Browse files Browse the repository at this point in the history
  • Loading branch information
xfoxfu committed Oct 6, 2024
1 parent 24a444a commit 44f4711
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Net.Vatprc.Uniapi/Controllers/SectorController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ public SectorPermissionResponse(bool hasPermission)
}
}

static readonly IEnumerable<string> AllowedRoles =
[
"Online Permission",
"ATC Student",
"S3 Controller",
"S2 Controller",
"S1 Controller",
"C1 Controller",
"C3 Controller",
];

[HttpGet("current/permission")]
public async Task<SectorPermissionResponse> GetPermission()
{
Expand All @@ -42,7 +53,7 @@ public async Task<SectorPermissionResponse> GetPermission()
{
return new SectorPermissionResponse(false);
}
var hasPermission = atc.Roles.Any(r => r.Name == "Online Permission" || r.Name == "ATC Student");
var hasPermission = atc.Roles.Any(r => AllowedRoles.Contains(r.Name));
return new SectorPermissionResponse(hasPermission);
}
}

0 comments on commit 44f4711

Please sign in to comment.