本文整理汇总了C#中UserModel.ValidateHash方法的典型用法代码示例。如果您正苦于以下问题:C# UserModel.ValidateHash方法的具体用法?C# UserModel.ValidateHash怎么用?C# UserModel.ValidateHash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserModel
的用法示例。
在下文中一共展示了UserModel.ValidateHash方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PasswordReset
public ActionResult PasswordReset(UserModel.User user)
{
try
{
if (ModelState.IsValid)
{
var regexItem = new Regex(@"\d");
var hashValue = Request.Form["hash"];
//Validate password
if (user.ResetPasswordOne != user.ResetPasswordTwo)
{
ModelState.AddModelError("", "Password is incorrect");
return View();
}
else if (user.ResetPasswordOne.Length < 6)
{
ModelState.AddModelError("", "Password is incorrect");
return View();
}
else if (!regexItem.IsMatch(user.ResetPasswordOne))
{
ModelState.AddModelError("", "Password is incorrect");
return View();
}
//Validate hash and save new password
var passwordUpdateStatus = user.ValidateHash(hashValue, user.ResetPasswordOne);
if (passwordUpdateStatus == HashValidation.Validated)
{
//Login view
return RedirectToAction("ResetViewBeforeLogin", "Home");
}
else if (passwordUpdateStatus == HashValidation.Expired)
{
//Expired hash action
return RedirectToAction("ExpiredLink", "Home");
}
else if (passwordUpdateStatus == HashValidation.NotFound)
{
//Error view
return RedirectToAction("Error", "User");
}
}
return View();
}
catch (Exception ex)
{
Logger.WriteErrorLog(ex);
return View();
}
}