/// <summary> /// 判断用户是否有权限 /// </summary> public static bool HasRights(ControllerBase controller, string action) { if (!IsLogin) return false; if (LoginUser.UserName == "admin") return true; UserDal userDal = new UserDal(); List<FunctionModel> functionList = userDal.GetFunctionListByUserName(LoginUser.UserName); if (functionList.Exists(item => item.Controller == controller.GetType().FullName && item.Action == action)) { return true; } return false; }
/// <summary> /// 登录 /// </summary> public static bool Login(string userName, string pwd) { UserDal userDal = new UserDal(); UserModel userModel = userDal.GetByUserName(userName); if (userModel != null) { if (userModel.Pwd == MD5Helper.Encrypt(pwd)) { HttpContext.Current.Session["_sysAuth"] = userModel; return true; } } return false; }