public async Task <IActionResult> CheckPermission(CheckPermissionModel model) { var adminUser = await AdminSvc.GetByIdAsync(model.AdminUserId); if (adminUser == null) { return(new JsonResult(new APIResult <long> { ErrorMsg = "管理员不存在" }) { StatusCode = 400 }); } var permission = await PerSvc.GetByNameAsync(model.PermissionName); if (permission == null) { return(new JsonResult(new APIResult <long> { ErrorMsg = "权限名不存在" }) { StatusCode = 400 }); } return(new JsonResult(new APIResult <bool> { Data = await PerSvc.CheckPermissionAsync(model.AdminUserId, model.PermissionName) })); }
public async Task <IActionResult> CheckPermission(string perName) { string token = JWTHelper.GetToken(HttpContext, "token"); if (!JWTHelper.Decrypt(token, out ListAdminUserDTO adminUser)) { return(new JsonResult(new APIResult <long> { ErrorMsg = "请先登录!" }) { StatusCode = 401 }); } if (await PerSvc.CheckPermissionAsync(adminUser.Id, perName)) { return(Ok()); } return(Unauthorized()); }