public ActionResult AdminPermissions(Permissions model) { PermissionManagement permissionMgt = new PermissionManagement(User.Identity.GetUserId<int>()); if (!permissionMgt.CurrentLoginUser.IsSuperAdmin && !permissionMgt.CurrentLoginUser.IsWebMaster) { ViewBag.Message = "只有超级管理员和站长才能编辑管理员权限"; return View("Error"); } if (ModelState.IsValid) { int id = int.Parse(Request["userId"]); permissionMgt.GrantUserPermissions(id, model); return Redirect("/Admin/Administrators"); } return View(model); }
static void Main(string[] args) { Logger = KMLogger.GetLogger(); args = new string[] { "getstatus" }; if (args.Length==0) { Console.WriteLine("Please provide the command."); return; } string command = args[0]; Logger.Info("command:"+command); switch (command) { case "syncpermissions": PermissionManagement pgt = new PermissionManagement(3); pgt.SyncPermissionsWithDB(); break; case "getstatus": //GetStatus(); Console.WriteLine("Six threads will be started in every 8 seconds to query order status..."); Logger.Info("Six threads will be started in every 8 seconds to query order status..."); GetStatus(); break; case "qr": if(args.Length<=1 || string.IsNullOrEmpty(args[1])) { Console.WriteLine("Content cannot be empty when trying to generate qr file."); return; } GenerateQRFile(args[1]); break; default: break; } }
public ActionResult AdminPermissions(int userId) { if(userId==0) { return View("Error"); } PermissionManagement permissionMgt = new PermissionManagement(User.Identity.GetUserId<int>()); if(!permissionMgt.CurrentLoginUser.IsSuperAdmin && !permissionMgt.CurrentLoginUser.IsWebMaster) { ViewBag.Message = "只有超级管理员和站长才能查看或编辑管理员权限"; return View("Error"); } BUser user = permissionMgt.GetUserInfo(userId); Permissions permissions = user.Permission; ViewBag.User = user; return View(permissions); }