예제 #1
0
        //skal hente fra Superuser tabell da, flytter til AdminDAL
        //metode returnerer brukernavn til superuser for å sette den i session videre
        //Tetiana
        public SuperuserDTO Superbruker_i_DB(SuperuserDTO inSuperuser)
        {
            byte[] passwordDb     = SvarbotDAL.MakeHash(inSuperuser.Password);
            var    superUser      = _dbContext.Superuser.FirstOrDefault(b => b.Username.ToLower() == inSuperuser.Username);
            var    foundSuperuser = superUser.Password.SequenceEqual(passwordDb) ? superUser : null;

            if (foundSuperuser == null)
            {
                //RegistrerSuperUser(inSuperuser);
                return(null);
            }
            else
            {
                SuperuserDTO verifyUserName = new SuperuserDTO();
                verifyUserName.Username = foundSuperuser.Username;
                return(verifyUserName);
            }
        }
예제 #2
0
        public ActionResult AdminLoggInn(SuperuserDTO superuserDTO)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            var adminuser = adminBL.SuperuserInDb(superuserDTO);

            if (adminuser != null)
            {
                Session["AdminLoggedIn"] = adminuser.Username;
                return(RedirectToAction("Dashboard", "Admin"));
            }
            else
            {
                Session["AdminLoggedIn"] = null;
                ModelState.AddModelError("", "Feil brukernavn eller passord");
                return(View());
            }
        }
예제 #3
0
 public SuperuserDTO SuperuserInDb(SuperuserDTO InSuperDTO)
 {
     return(adminDAL.Superbruker_i_DB(InSuperDTO));
 }