コード例 #1
0
 public bool EndrePassord(AdminPassordViewModel adminViewModel)
 {
     if (adminViewModel.Username != "root" && adminViewModel.Nytt == adminViewModel.NyttBekreft && adminViewModel.Gammelt != null)
     {
         return(true);
     }
     return(false);
 }
コード例 #2
0
 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);
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 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");
 }
コード例 #7
0
        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);
        }