Beispiel #1
0
        public ActionResult LogOn(LogOnModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                User user1 = UsersService1.getUserLogIn(model.UserName, model.Password);
                if (user1 != null)
                {
                    var check = newsServices.CheckAboutNewByUser(user1);
                    Session[USER_HASH_NEWINFO] = check;
                    if (Request.QueryString["ReturnUrl"] != null)
                    {
                        Session[USER_SESSION_ID] = user1;
                        FormsAuthentication.RedirectFromLoginPage(model.UserName, false);
                    }
                    else
                    {
                        FormsAuthentication.SetAuthCookie(model.UserName, false);
                        return(RedirectToAction("Index", "Users", new { id = 0 }));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }