ResetPassword() public method

public ResetPassword ( ApplicationUser user, string code, string password ) : Microsoft.AspNet.Identity.IdentityResult
user ApplicationUser
code string
password string
return Microsoft.AspNet.Identity.IdentityResult
コード例 #1
0
		public async Task<ActionResult> ForgotPassword(ForgotPasswordViewModel model) {
			if (ModelState.IsValid) {
				var user = await securityHelper.UserManager.FindByEmailAsync(model.Email);
				if (user == null) {
					// Don't reveal that the user does not exist or is not confirmed
					return View("ForgotPasswordConfirmation");
				} else {
					SecurityData sd = new SecurityData();
					sd.ResetPassword(model.Email);
					return RedirectToAction("ForgotPasswordConfirmation");
				}
			}

			Helper.HandleErrorDict(ModelState);
			// If we got this far, something failed, redisplay form
			return View(model);
		}
コード例 #2
0
		public async Task<ActionResult> ResetPassword(ResetPasswordInfo model) {
			model.ReconstructSettings();
			this.ViewData[ResetPasswordInfo.Key] = model;

			LoadPage(model.Settings.Uri);

			var settings = model.Settings;

			if (settings.UseValidateHuman) {
				bool IsValidated = model.ValidateHuman.ValidateValue(model.ValidationValue);
				if (!IsValidated) {
					ModelState.AddModelError("ValidationValue", model.ValidateHuman.AltValidationFailText);
					model.ValidationValue = String.Empty;
				}
			}

			if (String.IsNullOrEmpty(settings.UserCode)) {
				ModelState.AddModelError(String.Empty, "Reset code not provided.");
			}

			if (ModelState.IsValid) {
				string confirmView = settings.PostPartialName;
				if (!String.IsNullOrEmpty(settings.PostPartialName)) {
					confirmView = settings.PostPartialConfirmation;
				}

				var user = await securityHelper.UserManager.FindByEmailAsync(model.Email);
				if (user == null) {
					return PartialView(confirmView, model);
				} else {
					SecurityData sd = new SecurityData();
					var result = sd.ResetPassword(user, settings.UserCode, model.Password);
					model.CreationResult = result;

					if (result.Succeeded) {
						return PartialView(confirmView, model);
					}

					AddErrors(result);
				}
			}

			Helper.HandleErrorDict(ModelState);

			return PartialView(settings.PostPartialName, model);
		}
コード例 #3
0
		public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model) {
			if (!ModelState.IsValid) {
				Helper.HandleErrorDict(ModelState);

				return View(model);
			}

			//var user = await UserManager.FindByNameAsync(model.Email);
			var user = await securityHelper.UserManager.FindByEmailAsync(model.Email);
			if (user == null) {
				// Don't reveal that the user does not exist
				return RedirectToAction("ResetPasswordConfirmation");
			}
			//var result = await manage.UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);
			SecurityData sd = new SecurityData();
			var result = sd.ResetPassword(user, model.Code, model.Password);
			if (result.Succeeded) {
				return RedirectToAction("ResetPasswordConfirmation");
			}
			AddErrors(result);

			Helper.HandleErrorDict(ModelState);
			return View();
		}
コード例 #4
0
		public async Task<ActionResult> ForgotPassword(ForgotPasswordInfo model) {
			model.ReconstructSettings();
			this.ViewData[ForgotPasswordInfo.Key] = model;

			LoadPage(model.Settings.Uri);

			var settings = model.Settings;

			if (settings.UseValidateHuman) {
				bool IsValidated = model.ValidateHuman.ValidateValue(model.ValidationValue);
				if (!IsValidated) {
					ModelState.AddModelError("ValidationValue", model.ValidateHuman.AltValidationFailText);
					model.ValidationValue = String.Empty;
				}
			}

			string confirmView = settings.PostPartialName;
			if (!String.IsNullOrEmpty(settings.PostPartialName)) {
				confirmView = settings.PostPartialConfirmation;
			}

			string confirmUri = settings.Uri;
			if (!String.IsNullOrEmpty(settings.ConfirmUri)) {
				confirmUri = settings.ConfirmUri;
			}

			if (ModelState.IsValid) {
				var user = await securityHelper.UserManager.FindByEmailAsync(model.Email);
				if (user != null) {
					SecurityData sd = new SecurityData();
					sd.ResetPassword(confirmUri, model.Email);
				}

				return PartialView(confirmView, model);
			}

			Helper.HandleErrorDict(ModelState);

			return PartialView(settings.PostPartialName, model);
		}