Example #1
0
        public void CheckIfAdmin()
        {
            LoginLogic logic = new LoginLogic();

            CreateUser();
            CreateAdmin();
            Assert.IsTrue(logic.CheckIfAdmin("DeAdmin"), "Gebruiker bestaat niet");
            Assert.IsFalse(logic.CheckIfAdmin("Quinn2500"), "Gebruiker bestaat niet");
            db.DeleteUser("Quinn2500");
            db.DeleteUser("DeAdmin");
        }
Example #2
0
 public ActionResult Index(IndexModel model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     else
     {
         LoginLogic loginLogic = new LoginLogic();
         if (loginLogic.Login(model.Username, model.Password) != null)
         {
             HttpContext.Session.SetString("Username", model.Username);
             if (loginLogic.CheckIfAdmin(model.Username))
             {
                 return(RedirectToAction("Index", "Admin"));
             }
             else
             {
                 return(RedirectToAction("Index", "Dashboard"));
             }
         }
         else
         {
             TempData["Succes"] = "U bent niet ingelogd";
             return(RedirectToAction("Index"));
         }
     }
 }
        public void AccountLogic()
        {
            LoginLogic   loginLogic = new LoginLogic();
            AccountLogic logic      = new AccountLogic();

            logic.RegisterUser(new Gebruiker()
            {
                Email     = "*****@*****.**",
                Username  = "******",
                FirstName = "Quinn",
                LastName  = "van Veen",
                Password  = "******"
            });
            Assert.IsNotNull(logic.CheckIfUserExitst("Quinn2500"), "De gèbruiker is niet aangemaakt");
            Assert.IsNotNull(loginLogic.Login("Quinn2500", "@Appel1"), "Kan gebruiker niet inloggen");
            Assert.IsNull(loginLogic.Login("Quinn2500", "@Apel1"), "Kan gebruiker inloggen vanwege verkeer wachtwoord");
            CreateAdmin();
            Assert.IsTrue(loginLogic.CheckIfAdmin("DeAdmin"), "Gebruiker bestaat niet");
            Assert.IsFalse(loginLogic.CheckIfAdmin("Quinn2500"), "Gebruiker bestaat niet");
            db.DeleteUser("Quinn2500");
            db.DeleteUser("DeAdmin");
        }