public ActionResult Authorize(LoginModel loginUser) { UserModel u = new UserModel(); u.email = (string)loginUser.email; u.password = (string)loginUser.password; UserModel user = SqliteDataAccess.AuthorizeUser(u); if (ModelState.IsValid && user != null) { if (user.password == u.password) { Console.WriteLine("Authenticated!"); HttpContext.Session.SetString("UserSession", user.role); HttpContext.Session.SetString("UserName", user.fname); return(View("~/Views/Home/Dashboard.cshtml")); } else { Console.WriteLine("Access Denied!"); return(View("~/Views/Home/Login.cshtml")); } } else { Console.WriteLine("Access Denied!"); return(View("~/Views/Home/Login.cshtml")); } }
public ActionResult Authorize(LoginModel loginUser) { UserModel u = new UserModel(); u.email = (string)loginUser.email; u.password = (string)loginUser.password; UserModel user = SqliteDataAccess.AuthorizeUser(u); if (ModelState.IsValid && user != null) { //creates hash of inserted password with the salt that belongs to the username passwordEncryptionController hashPW = new passwordEncryptionController(); hashPW.setSalt(user.salt); var hash = hashPW.generateHash(u.password, true); Console.WriteLine("salt: " + user.salt); Console.WriteLine("hash: " + hash); Console.WriteLine("password: "******"Authenticated!"); HttpContext.Session.SetString("UserSession", user.role); HttpContext.Session.SetString("UserName", user.fname); HttpContext.Session.SetInt32("UserClub", user.club); HttpContext.Session.SetInt32("UserID", user.userID); return(RedirectToAction("Dashboard", "Home")); } else { Console.WriteLine("Access Denied!"); return(RedirectToAction("Login", "Home")); } } else { Console.WriteLine("Access Denied!"); return(RedirectToAction("Login", "Home")); } }