public bool EndrePassord(AdminPassordViewModel adminViewModel) { if (adminViewModel.Username != "root" && adminViewModel.Nytt == adminViewModel.NyttBekreft && adminViewModel.Gammelt != null) { return(true); } return(false); }
public bool EndrePassord(AdminPassordViewModel adminViewModel) { if (IsPassordGyldig(adminViewModel.Username, adminViewModel.Gammelt)) { if (adminViewModel.Nytt.Equals(adminViewModel.NyttBekreft)) { return(dbAdmin.EndrePassord(adminViewModel.Username, adminViewModel.Nytt)); } } return(false); }
public void EndreAdminSkalKunneEndrePassord() { var controller = NyAdminControllerMedSession(true); var adminPassordViewModel = new AdminPassordViewModel() { Username = "******", Gammelt = "Gammelt1", Nytt = "NyttPassord1", NyttBekreft = "NyttPassord1" }; var result = (string)controller.EndreAdmin(adminPassordViewModel); Assert.AreEqual("true", result); }
public void EndreAdminAltErGyldigMenBrukerErRoot() { var controller = NyAdminControllerMedSession(true); var adminPassordViewModel = new AdminPassordViewModel() { Username = "******", Gammelt = "Gammelt1", Nytt = "NyttPassord1", NyttBekreft = "NyttPassord1" }; var result = (string)controller.EndreAdmin(adminPassordViewModel); Assert.AreNotEqual("true", result); }
public void EndreAdminModelStateValidIkkeLeggeTil() { var controller = NyAdminControllerMedSession(true); var adminPassordViewModel = new AdminPassordViewModel() { Username = "******", Gammelt = "Gammelt1", Nytt = "NyttPassord1", NyttBekreft = "NyttP" // Model er gyldig, men nytt != nyttbekreft }; var result = (string)controller.EndreAdmin(adminPassordViewModel); Assert.AreNotEqual("true", result); }
public string EndreAdmin(AdminPassordViewModel adminViewModel) { if (ErAdmin()) { if (ModelState.IsValid) { if (blladmin.EndrePassord(adminViewModel)) { return("true"); } return("Klarte ikke å endre passord på " + adminViewModel.Username); } return("Feil input."); } return("Ikke admin"); }
public void EndreAdminModelStateNotValid() { var controller = NyAdminControllerMedSession(true); var adminPassordViewModel = new AdminPassordViewModel() { Username = null, Gammelt = null, Nytt = null, NyttBekreft = null }; controller.ModelState.AddModelError("Gammelt", "Feil"); var result = (string)controller.EndreAdmin(adminPassordViewModel); Assert.AreNotEqual("true", result); }