Beispiel #1
0
        public ActionResult Login(LoginViewModel loginModel, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(loginModel));
            }
            var result = ApiService.AuthenticateUser(loginModel.Username, loginModel.Password);

            if (result.Success)
            {
                FormsAuthentication.SetAuthCookie(loginModel.Username, true);
                Session["Username"] = loginModel.Username;
            }
            else
            {
                ModelState.AddModelError("", "Login data is incorrect!");
            }


            return(RedirectToAction("Index", "Home"));
        }