Esempio n. 1
0
 public void ValidModel_ExtraTrailingSlash()
 {
     var model = new SignInModel { Password = "******", ReturnUrl = "/Today/hanschristienanderson/" };
     var validationResults = new List<ValidationResult>();
     Assert.IsTrue(IsValid(model, validationResults));
     Assert.AreEqual(0, validationResults.Count);
 }
Esempio n. 2
0
 public void ValidModel()
 {
     var model = new SignInModel {Password="******", ReturnUrl = "/Today/Mark-Nopfler"};
     var validationResults = new List<ValidationResult>();
     Assert.IsTrue(IsValid(model, validationResults));
     Assert.AreEqual(0, validationResults.Count);
 }
Esempio n. 3
0
 public void Invalid_NullReturnUrl()
 {
     var model = new SignInModel { Password = "******" };
     var validationResults = new List<ValidationResult>();
     Assert.IsFalse(IsValid(model, validationResults));
     Assert.AreEqual("ReturnUrl", validationResults[0].MemberNames.First());
 }
Esempio n. 4
0
 public void Invalid_NullPassword()
 {
     var model = new SignInModel { ReturnUrl = "/Today/blah" };
     var validationResults = new List<ValidationResult>();
     Assert.IsFalse(IsValid(model, validationResults));
     Assert.AreEqual("Password", validationResults[0].MemberNames.First());
 }
Esempio n. 5
0
 public void InvalidReturnUrl_MissingAccount()
 {
     var model = new SignInModel { Password = "******", ReturnUrl = "/Today" };
     var validationResults = new List<ValidationResult>();
     Assert.IsTrue(IsValid(model, validationResults));
     Assert.AreEqual(0, validationResults.Count);
 }
Esempio n. 6
0
 public ActionResult SignIn(SignInModel model)
 {
     var account = _documentService.Query(new AccountByNameSlug(model.NameSlug)).FirstOrDefault();
     if (account==null) return RedirectToAction("Index", "Registration");
     if (account.IsCorrectPassword(model.Password))
     {
         FormsAuthentication.RedirectFromLoginPage(account.NameSlug, true);
         return Content(""); // required
     }
     return RedirectToAction("SignIn");
 }
Esempio n. 7
0
 private bool IsValid(SignInModel model, List<ValidationResult> results)
 {
     var validationContext = new ValidationContext(model, null, null);
     return Validator.TryValidateObject(model, validationContext, results);
 }
Esempio n. 8
0
 public void NameSlug_TrailingSlash()
 {
     var model = new SignInModel { Password = "******", ReturnUrl = "/Today/Mark-Nopfler/" };
     Assert.AreEqual("Mark-Nopfler", model.NameSlug);
 }