示例#1
0
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            var user = RavenSession.GetUserByUserName(model.UserName);

            if (user == null || user.ValidatePassword(model.Password) == false)
            {
                ModelState.AddModelError("UserNotExistOrPasswordNotMatch",
                                         "Email and password do not match to any known user.");
            }
            else if (user.Enabled == false)
            {
                ModelState.AddModelError("NotEnabled", "The user is not enabled");
            }

            if (ModelState.IsValid)
            {
                FormsAuthentication.SetAuthCookie(model.UserName, true);
                return(RedirectToLocal(returnUrl));
            }


            return(View(model));
        }