예제 #1
0
 public ActionResult Login(LoginViewModel model)
 {
     var errorMsg = string.Empty;
     try
     {
         User result = null;
         if (ModelState.IsValid)
         {
             if (string.Equals(model.code,
                 Session["validataCode"].ToString(),
                 StringComparison.InvariantCultureIgnoreCase))
             {
                 userService = new UserService();
                 result = userService.Login(model.username, model.password);
                 if (result != null)
                 {
                     Session[USERINFO] = result;
                     return RedirectToAction("Index", "User", new { Area = "M" });
                 }
                 else
                 {
                     errorMsg = "用户名或密码错误!";
                 }
             }
             else
             {
                 errorMsg = "验证码输入错误!";
             }
         }
         else
         {
             errorMsg = "信息填写有误!";
         }
     }
     catch (Exception ex)
     {
         LogService.Log("注册用户", ex.ToString());
     }
     model.ErrorMsg = errorMsg;
     return View(model);
 }