Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ActionResult LogOn(string myCaptcha,string attempt,User userToLogin,string returnUrl)
- {
- if (!CaptchaHelper.VerifyAndExpireSolution(HttpContext, myCaptcha, attempt))
- {
- // Redisply the view width an error message
- ModelState.AddModelError("", "验证码错误!");
- }
- if (ModelState.IsValid)
- {
- var users = unitOfWork.UsersRepository.Get(
- filter: x => x.UserName == userToLogin.UserName && x.Password == userToLogin.Password
- );
- if (users.Count() > 0) // login succeed
- {
- Session["UserID"] = users.First();
- return Redirect(returnUrl??"~/Admin");
- }
- else
- {
- ModelState.AddModelError(string.Empty, "登入失败,用户名或密码错误");
- }
- }
- return View();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement