Esempio n. 1
0
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
            {
                return RedirectToLocal(returnUrl);
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "The user name or password provided is incorrect.");
            return View(model);
        }
Esempio n. 2
0
        public ActionResult Login(LoginModel model)
        {
            if (ModelState.IsValid)
            {
                bool status = _accountService.ValidateLogin(model.Email, model.Password);
                if (status)
                {
                    FormsAuthentication.SetAuthCookie(model.Email, model.RememberMe);
                    ViewData["Status"] = "Login Successful";
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    Session["Error"] = "User Name/ Password Mismatch";
                    ViewData["Status"] = "Login Failure";
                    return RedirectToAction("Login", "Account");
                }

            }
            return RedirectToAction("Login", "Account");
        }