Exemple #1
0
        public bool LoggInn(LoggInnAdmin input)
        {
            var sikkerhet = new Sikkerhet();
            var admin = new AdminBruker()
            {
                mail = input.mail,
                passord = sikkerhet.LagHash(input.passord)
            };

            var ok = _aDAL.LoggInnAdmin(admin);
            return ok;
        }
        public void LoggInnOK()
        {
            var input = new LoggInnAdmin()
            {
                mail = "m",
                passord = "p"
            };

            var actionResult = (RedirectToRouteResult)_ctrl.LoggInn(input);

            Assert.AreEqual(actionResult.RouteValues["action"], "Index");
            Assert.AreEqual(_ctrl.Session["Admin"], true);
        }
        public void LoggInnFeil()
        {
            var input = new LoggInnAdmin();
            input.mail = "";
            input.passord = "p";

            var actionResult = (ViewResult)_ctrl.LoggInn(input);

            Assert.AreEqual(actionResult.ViewName, "");
            Assert.AreEqual(_ctrl.Session["Admin"], false);
        }
        public ActionResult LoggInn(LoggInnAdmin input)
        {
            var ok = _aBLL.LoggInn(input);

            if (ok)
            {
                Session["Admin"] = true;
                RedirectToAction("Index");
            }
            else
            {
                Session["Admin"] = false;
                ViewBag.Feil = "Innlogging feilet. Har du tastet riktig brukernavn og passord?";
            }
            return View();
        }