示例#1
0
        public ActionResult LogOn(LogOnModel model, string returnUrl)
        {
            if (!this.ValidateLogOn(model))
            {
                return this.View(model);
            }

            this.formsAuth.SignIn(model.UserName, model.RememberMe);
            if (!string.IsNullOrEmpty(returnUrl))
            {
                return this.Redirect(returnUrl);
            }
            else
            {
                return this.RedirectToAction("Index", "Home");
            }
        }
示例#2
0
        private bool ValidateLogOn(LogOnModel model)
        {
            if (string.IsNullOrWhiteSpace(model.UserName))
            {
                this.ModelState.AddModelError("username", "You must specify a username.");
            }

            if (string.IsNullOrEmpty(model.Password))
            {
                this.ModelState.AddModelError("password", "You must specify a password.");
            }

            if (!this.membershipService.ValidateUser(model.UserName, model.Password))
            {
                this.ModelState.AddModelError("", "The username or password provided is incorrect.");
            }

            return ModelState.IsValid;
        }