public ActionResult Login(User user) { PublicStruct <User, string> outInfo; bool flag = _userService.Login(user.UserName, user.UserPwd, out outInfo); if (flag) { string sessionId = Guid.NewGuid().ToString(); Response.Cookies["sessionId"].Value = sessionId; if (!string.IsNullOrEmpty(Request["rememberMe"])) { //记住我,添加到cookie HttpCookie userName = new HttpCookie("username", user.UserName); HttpCookie passWord = new HttpCookie("password", FuncUtility.Encrypt(user.UserPwd)); userName.Expires = DateTime.Now.AddDays(3); passWord.Expires = DateTime.Now.AddDays(3); Response.Cookies.Add(userName); Response.Cookies.Add(passWord); } if (!string.IsNullOrEmpty(Request["from"])) { return(Redirect(Request["from"])); } else { return(RedirectToAction("Index", "WolfLair")); } } else { ViewData["msg"] = outInfo.String; } return(View()); }
public ActionResult Register(User user) { if (CheckVCode()) { user.RegisterTime = DateTime.Now; user.UserPwd = FuncUtility.Encrypt(user.UserPwd); string msg = string.Empty; if (_userService.AddEntity(user, out msg)) { return(RedirectToAction("Login", "Account")); } _userService.AddEntity(user); } else { ViewData["msg"] = "验证码错误!"; } return(View()); }
public bool Login(string userName, string passWord, out PublicStruct <User, string> outInfo) { outInfo = new PublicStruct <User, string>(); outInfo.Class = this.DBSession.UserDal.Select(c => c.UserName.Equals(userName)).FirstOrDefault(); if (outInfo.Class != null) { if (outInfo.Class.UserPwd.Equals(FuncUtility.Encrypt(passWord))) { outInfo.String = "success login"; return(true); } else { outInfo.String = "username or password error"; return(false); } } else { outInfo.String = "username not exists"; return(false); } }
public override void Execute() { this.data = FuncUtility.GetStrFromFile(this.file); base.Execute(); }
public override void Execute() { isSuc = FuncUtility.SaveStrToFile(this.data, this.file); base.Execute(); }
public Delegate GetDelegate(params Type[] parameterTypes) { return(GetDelegate(FuncUtility.MakeClosedType(typeof(TResult), parameterTypes))); }