public ActionResult Edit(int id, UserBLL edit) { try { using (BusinessLogicLayer.ContextBLL ctx = new BusinessLogicLayer.ContextBLL()) ctx.UserUpdateJust(id, edit.UserName, edit.Email, edit.Address, edit.Hash, edit.Salt, edit.RoleID); // TODO: Add update logic here return(RedirectToAction("Index")); } catch (Exception ex) { Logger.Logger.Log(ex); return(View("Error")); } }
public ActionResult Hash() { if (!User.Identity.IsAuthenticated) { return(View("NotLoggedIn")); } if (User.Identity.AuthenticationType.StartsWith("HASHED")) { return(View("AlreadyHashed")); } using (BusinessLogicLayer.ContextBLL ctx = new BusinessLogicLayer.ContextBLL()) { try { BusinessLogicLayer.UserBLL user = ctx.UserFindByEMail(User.Identity.Name); if (user == null) { Exception Message = new Exception($"The UserName '{User.Identity.Name}' doesn't exist in the database."); ViewBag.Exception = Message; return(View("Error")); } user.Salt = System.Web.Helpers.Crypto.GenerateSalt(MuhConstants.SaltSize); user.Hash = System.Web.Helpers.Crypto.HashPassword(user.Hash + user.Salt); ctx.UserUpdateJust(user); string ValidationType = $"HASHED:({user.UserID})"; Session["AUTHUserName"] = user.Email; Session["AUTHRoles"] = user.RoleID; Session["AUTHTYPE"] = ValidationType; } catch (Exception ex) { Logger.Logger.Log(ex); } return(RedirectToAction("Index", "Home")); } }