public LoginController(Sys_UserBLL userbll) { this.userbll = userbll; this.appsettings = base.AppSettings; }
/// <summary> /// 处理登录的信息 /// </summary> /// <param name="userInfo"></param> /// <param name="CookieExpires">cookie有效期</param> /// <returns></returns> public ActionResult CheckUserLogin(Sys_User userInfo, string CookieExpires, string code) { try { if (string.IsNullOrEmpty(Session["nfine_session_verifycode"].ToString()) || Md5.md5(code.ToLower(), 16) != Session["nfine_session_verifycode"].ToString()) { throw new Exception("验证码错误,请重新输入"); } AchieveEntity.Sys_User currentUser = new Sys_UserBLL().UserLogin(userInfo.F_Account, userInfo.F_Password); if (currentUser != null) { if (currentUser.F_EnabledMark == false) { //return Content(""); return(Json(new AjaxResult { state = ResultType.warning.ToString(), message = "用户已被禁用,请您联系管理员" })); } //记录登录cookie //CookiesHelper.SetCookie("UserID", AES.EncryptStr(currentUser.F_Id.ToString())); //CookiesHelper.SetCookie("UserAccount", AES.EncryptStr(currentUser.F_Account.ToString())); //CookiesHelper.SetCookie("UserName", AES.EncryptStr(currentUser.F_RealName.ToString())); //CookiesHelper.SetCookie("UserRoleId", AES.EncryptStr(currentUser.F_RoleId.ToString())); OperatorModel operatorModel = new OperatorModel(); operatorModel.UserId = currentUser.F_Id; operatorModel.UserCode = currentUser.F_Account; operatorModel.UserName = currentUser.F_RealName; operatorModel.CompanyId = currentUser.F_OrganizeId; operatorModel.DepartmentId = currentUser.F_DepartmentId; operatorModel.RoleId = currentUser.F_RoleId; operatorModel.LoginIPAddress = Net.Ip; operatorModel.LoginIPAddressName = Net.GetLocation(operatorModel.LoginIPAddress); operatorModel.LoginTime = DateTime.Now; //operatorModel.LoginToken = DESEncrypt.Encrypt(Guid.NewGuid().ToString()); if (currentUser.F_Account == "admin") { operatorModel.IsSystem = true; } else { operatorModel.IsSystem = false; } OperatorProvider.Provider.AddCurrent(operatorModel); return(Json(new AjaxResult { state = ResultType.success.ToString(), message = "登录成功。" })); } else { return(Json(new AjaxResult { state = ResultType.warning.ToString(), message = "用户名或密码错误。" })); } } catch (Exception ex) { return(Json(new AjaxResult { state = ResultType.error.ToString(), message = ex.Message })); } }
public ActionResult CheckLogin(string username, string password, string code) { Sys_UserBLL userbll = new Sys_UserBLL(); Sys_UserModel usermodel = new Sys_UserModel(); Sys_LogModel logModel = new Sys_LogModel(); Sys_LogBLL logbll = new Sys_LogBLL(); logModel.F_ModuleName = "系统登录"; logModel.F_Type = DbLogType.Login.ToString(); try { //if (Session["nfine_session_verifycode"].IsEmpty() || Md5.md5(code.ToLower(), 16) != Session["nfine_session_verifycode"].ToString()) //{ // throw new Exception("验证码错误,请重新输入"); //} usermodel = userbll.CheckLogin(username, password); if (usermodel != null) { OperatorModel operatorModel = new OperatorModel(); operatorModel.UserId = usermodel.F_Id; operatorModel.UserCode = usermodel.F_Account; operatorModel.UserName = usermodel.F_RealName; operatorModel.CompanyId = usermodel.F_OrganizeId; operatorModel.DepartmentId = usermodel.F_DepartmentId; operatorModel.RoleId = usermodel.F_RoleId; operatorModel.LoginIPAddress = Net.Ip; operatorModel.LoginIPAddressName = Net.GetLocation(operatorModel.LoginIPAddress); operatorModel.LoginTime = DateTime.Now; operatorModel.LoginToken = DESEncrypt.Encrypt(Guid.NewGuid().ToString()); if (usermodel.F_Account == "admin") { operatorModel.IsSystem = true; } else { operatorModel.IsSystem = false; } OperatorProvider.Provider.AddCurrent(operatorModel); logModel.F_Account = usermodel.F_Account; logModel.F_NickName = usermodel.F_RealName; logModel.F_Result = true; logModel.F_Description = "登录成功"; logModel.F_Id = Common.GuId(); logModel.F_Date = DateTime.Now; logModel.F_IPAddress = Net.Ip; logModel.F_IPAddressName = Net.GetLocation(logModel.F_IPAddress); logbll.Add(logModel); } return(Content(new AjaxResult { state = ResultType.success.ToString(), message = "登录成功。" }.ToJson())); } catch (Exception ex) { logModel.F_Account = username; logModel.F_NickName = username; logModel.F_Result = false; logModel.F_Description = "登录失败," + ex.Message; logModel.F_Id = Common.GuId(); logModel.F_Date = DateTime.Now; logModel.F_IPAddress = Net.Ip; logModel.F_IPAddressName = Net.GetLocation(logModel.F_IPAddress); logbll.Add(logModel); return(Content(new AjaxResult { state = ResultType.error.ToString(), message = ex.Message }.ToJson())); } }
public void ButtonGetCountTest() { ISys_ButtonBLL button = new Sys_buttonBLL(); ISys_UserBLL user = new Sys_UserBLL(); }
private void Init(PermissionEnum mode) { appsetting = ConfigHelper.GetAppSetting(); EnumModel = mode; bll = new Sys_UserBLL(); }
public UserController(Sys_UserBLL userbll, Sys_DictionaryBLL dicbll) { this.userbll = userbll; this.dicbll = dicbll; this.appsettings = base.AppSettings; }
public Sys_UserController(Sys_UserBLL Bll) { bll = Bll; }