public ActionResult LoginAuthentication(string userName, string password, bool RememberBox) { Security active = new Security(); var UController = new UsersController(); SecurityController SController = new SecurityController(active); IVM model = new LoginVM(active.IsLoggedIn, active); var user = UController.GetU(userName); if (user != null) { var saltHash = user.PassSalt; var encodedPassword = UController.HashPassword(password, saltHash); if (user.PassHash.Trim() == encodedPassword.Trim()) { SController.Login(userName); SController.SetRemember(RememberBox); Login(SController); model = new InventoryVM(userName.Trim(), SController.GetActive()); return(View("Inventory", model)); } else { ViewBag.ErrorMessage = "Invalid Password"; } } else { ViewBag.ErrorMessage = "Invalid User Name"; } return(View("Index", model)); }
public ActionResult Registration(string actives, string activeLog, string activeRem) { Security active = session(actives, activeLog, activeRem); SecurityController Active = new SecurityController(active); IVM model = new SecurityVM(active); if (IsLoggedIn(Active).CheckLogin()) { model = new InventoryVM(Active.GetID(), Active.GetActive()); return(View("Inventory", model)); } return(View(model)); }
public ActionResult PutUser(string FirstName, string LastName, string Organization, string PassHash, string actives, string activeLog, string activeRem, string CurrentPassword, string NewPassword) { Security active = session(actives, activeLog, activeRem); UsersController u = new UsersController(); SecurityController SController = new SecurityController(active); IVM model; var getUser = u.GetU(SController.GetID().Trim()); if (getUser.PassHash.Trim() == u.HashPassword(CurrentPassword, getUser.PassSalt).Trim()) { if (FirstName == null) { FirstName = ""; } if (LastName == null) { LastName = ""; } if (Organization == null) { Organization = ""; } getUser.FName = FirstName; getUser.LName = LastName; getUser.Organization = Organization; getUser.PassHash = u.HashPassword(NewPassword, getUser.PassSalt); UController.PutUser(getUser.ID, getUser); ViewBag.ErrorMessage = "Account Info Updated"; //return View("Account", model); } else { ViewBag.ErrorMessage = "Invalid Password"; } model = new AccountVM(SController.GetID(), SController.GetActive()); return(View("Account", model)); }