This commit is contained in:
王炜翔 2024-09-07 11:15:10 +08:00
parent 6ca43f5d37
commit af59007db1

View File

@ -225,20 +225,13 @@ namespace asg_form.Controllers
public async Task<ActionResult<object>> Gethaveop() public async Task<ActionResult<object>> Gethaveop()
{ {
if (this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
{
using (TestDbContext ctx = new TestDbContext()) using (TestDbContext ctx = new TestDbContext())
{ {
object data = userManager.Users.Select(a => new { a.Id, a.UserName, a.chinaname, a.Email, a.officium }).Where(a => a.officium != null).GroupBy(a => a.officium).ToList(); object data = userManager.Users.Select(a => new { a.Id, a.UserName, a.chinaname, a.Email, a.officium }).Where(a => a.officium != null).GroupBy(a => a.officium).ToList();
return data; return data;
} }
}
else
{
return BadRequest(new error_mb { code = 400, message = "无权访问" });
}
} }