//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); } }
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()); } }
public SuperuserDTO SuperuserInDb(SuperuserDTO InSuperDTO) { return(adminDAL.Superbruker_i_DB(InSuperDTO)); }