Beispiel #1
0
        public ActionResult ClientLogin(LoginModel model)
        {
            if (ModelState.IsValid)
            {
                // Get user info
                var user = UserService.ValidateUser(model.Username, model.Password);

                //IUserManager manager = ManagerFactory.Create(this._repository, model.CategoryID);
                if (user != null && user.UserID > 0)
                {
                    UserInfo info = UIHelper.BuildUserInfo(user);
                    SessionManager.UserInfo = info;
                    persistUser(info, model.RememberMe);

                    return RedirectToAction("Restricted", "Dashboard", new { Area="Administration"});
                }
                else
                {
                    ViewData["Message"] = string.Format(
                        "Tên hoặc mật khẩu không đúng. vui lòng kiểm tra lại!");

                    return View(model);
                }
            }

            return View(model);
        }
Beispiel #2
0
        public ActionResult Index( LoginModel model)
        {
            if (ModelState.IsValid)
            {
                // Get user info

                var user = UserService.ValidateUser(model.Username, model.Password);

                if (user != null && user.UserID > 0)
                {
                    UserInfo info = UIHelper.BuildUserInfo(user);
                    persistUser(info, model.RememberMe);

                    SessionManager.UserInfo = info;
                    if (!string.IsNullOrEmpty(Request["ReturnUrl"]) && !Request["ReturnUrl"].Contains("AccessDenied"))

                    {
                        return Redirect(Request["ReturnUrl"]);
                    }
                    return RedirectToAction("Index", "Dashboard");
                }
                else
                {
                    ViewData["Message"] = string.Format(
                        "Invalid username/password combination. Please try again.");

                    return View(model);
                }
            }

            return View(model);
        }