本文整理汇总了C#中ResetPasswordViewModel类的典型用法代码示例。如果您正苦于以下问题:C# ResetPasswordViewModel类的具体用法?C# ResetPasswordViewModel怎么用?C# ResetPasswordViewModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResetPasswordViewModel类属于命名空间,在下文中一共展示了ResetPasswordViewModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResetPassword
public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model)
{
if (!ModelState.IsValid)
{
return View(model);
}
var user = await UserManager.FindByNameAsync(model.Email);
if (user == null)
{
// Don't reveal that the user does not exist
return RedirectToAction("ResetPasswordConfirmation", "User");
}
if (model.Password != model.ConfirmPassword)
{
ModelState.AddModelError("", "Password and Confirm Password Mismatch");
return View();
}
var result = await UserManager.ResetPasswordAsync(user.Id, model.Code.Replace(" ", "+"), model.Password);
if (result.Succeeded)
{
return RedirectToAction("ResetPasswordConfirmation", "User");
}
AddErrors(result);
return View();
}
示例2: ResetPassword
public ActionResult ResetPassword(ResetPasswordViewModel model)
{
if (!ModelState.IsValid)
return Json(new ServiceOperationResult(false) {Message = Main.InvalidForm});
return Json(PiServices.UserService.ChangePassword(model));
}
示例3: TryResetPassword
private ActionResult TryResetPassword(ResetPasswordViewModel model)
{
try
{
var tokenValidation = this.Service.ValidateResetToken(model.ResetToken);
if (tokenValidation.Type == ResetToken.ResetType.Both)
{
if (!this.Service.IsPasswordStrengthPassed(model.Password))
throw new WeakPasswordException();
SavePasswordToSession(model.Password);
return RedirectToAction("ResetSecurePhrase", new { resetToken = model.ResetToken });
}
this.Service.FinishResetPassword(model.ResetToken, model.Password);
return RedirectToAction("ResetPasswordConfirmation");
}
catch (InvalidResetTokenException)
{
AddModelStateError(GlobalStrings.ResetTokenIsInvalid);
}
catch (WeakPasswordException)
{
AddModelStateError(GlobalStrings.WeakPassword);
}
catch (Exception)
{
AddModelStateError(GlobalStrings.SomethingWentWrong);
}
return View(model);
}
示例4: ResetPassword
public ActionResult ResetPassword(ResetPasswordViewModel model)
{
if (ModelState.IsValid)
return TryResetPassword(model);
// If we got this far, something failed, redisplay form
return View(model);
}
示例5: ResetPasswordView
private ActionResult ResetPasswordView(string resetToken)
{
var model = new ResetPasswordViewModel()
{
ResetToken = resetToken,
};
return View(model);
}
示例6: ChangePassword
public ServiceOperationResult ChangePassword(ResetPasswordViewModel model)
{
User user = UserRepository.GetUser(UserName);
if(user.Password != HashHelpers.GetSHA256Hash(model.OldPassword, user.Salt.ToString()))
{
return new ServiceOperationResult(false) {Message = Main.OldPasswordInvalid};
}
return Mapper.Map<DataResult, ServiceOperationResult>(UserRepository.ChangePassword(user, model.NewPassword));
}
示例7: ResetPassword
public ActionResult ResetPassword(string userName)
{
var model = new ResetPasswordViewModel()
{
Username = userName,
NewPassword = "123456" // generate
};
// reset the password
return View(model);
}
示例8: ResetPassword
public ActionResult ResetPassword(ResetPasswordViewModel model)
{
if(ModelState.IsValid)
{
membershipService.ResetPassword(model.Username);
membershipService.Commit();
SuccessMessage(FormMessages.AccountResetPassword);
return RedirectToAction("Index", "Home");
}
return View(model);
}
示例9: ResetPassword
public ActionResult ResetPassword(string code)
{
if (code == null)
{
return View("Error");
}
ResetPasswordViewModel md = new ResetPasswordViewModel()
{
Code = code
};
return View(md);
}
示例10: Index
public ActionResult Index(ResetPasswordViewModel rp)
{
//get the email from the URL
string email = Request.QueryString["user_email"];
//collect the data from the form
if (ModelState.IsValid)
{
if (!SecurityHelper.StripHTML(rp.Password).Equals(SecurityHelper.StripHTML(rp.ConfPassword))) //the passwords have to match
{
ViewBag.Message = "The two passwords have to match.";
return View("ResetPassword");
}
else //made it through both checks
{
var collectUser = (
from usr in db.Users
where usr.email.Equals(SecurityHelper.StripHTML(email))
select usr
).First();
collectUser.password = AuthenticationHelper.ENCRYPT_ME(SecurityHelper.StripHTML(rp.Password));
try
{
db.SaveChanges();
return RedirectToAction("Index", "Login");
}
catch (Exception ex)
{
ViewBag.Message = "Something weird happened. Try again.";
return View("ResetPassword");
}
}
}
else
{
ViewBag.Message = "You have to fill in both fields.";
return View("ResetPassword");
}
}
示例11: ResetPassword
public ActionResult ResetPassword(int userId, string token)
{
var model = new ResetPasswordViewModel()
{
Token = token,
UserId = userId
};
return token == null ? View("Error") : View(model);
}
示例12: ResetPassword
public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model)
{
if (ModelState.IsValid)
{
var user = await UserManager.FindByNameAsync(model.Email);
if (user == null)
{
ModelState.AddModelError("", "找不到用户。");
return View();
}
IdentityResult result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);
if (result.Succeeded)
{
return RedirectToAction("ResetPasswordConfirmation", "Account");
}
else
{
AddErrors(result);
return View();
}
}
// 如果我们进行到这一步时某个地方出错,则重新显示表单
return View(model);
}
示例13: ResetPassword
public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model)
{
if (!this.ModelState.IsValid)
{
return this.View(model);
}
var user = await this.UserManager.FindByNameAsync(model.Email);
if (user == null)
{
// Don't reveal that the user does not exist
return this.RedirectToAction("ResetPasswordConfirmation", "Account");
}
var result = await this.UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);
if (result.Succeeded)
{
return this.RedirectToAction("ResetPasswordConfirmation", "Account");
}
this.AddErrors(result);
return this.View();
}
示例14: ResetPassword
public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model)
{
if (ModelState.IsValid)
{
var user = await UserManager.FindByNameAsync(model.Email);
if (user == null)
{
ModelState.AddModelError("", "Es wurde kein Benutzer gefunden.");
return View();
}
IdentityResult result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);
if (result.Succeeded)
{
return RedirectToAction("ResetPasswordConfirmation", "Account");
}
else
{
AddErrors(result);
return View();
}
}
// Wurde dieser Punkt erreicht, ist ein Fehler aufgetreten. Formular erneut anzeigen.
return View(model);
}
示例15: ResetPassword
public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model)
{
if (ModelState.IsValid)
{
var user = await UserManager.FindByNameAsync(model.Email);
if (user == null)
{
ModelState.AddModelError("", "No se encontró ningún usuario.");
return View();
}
IdentityResult result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);
if (result.Succeeded)
{
return RedirectToAction("ResetPasswordConfirmation", "Account");
}
else
{
AddErrors(result);
return View();
}
}
// Si llegamos a este punto, es que se ha producido un error y volvemos a mostrar el formulario
return View(model);
}