Пример #1
0
		public async Task<ActionResult> SetPassword(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", "Account");
			}
			var result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);
			if (result.Succeeded)
			{
				return RedirectToAction("List");
			}
			AddErrors(result);
			return View();
		}
Пример #2
0
		public ActionResult SetPassword(string id)
		{
			#region validation

			if (string.IsNullOrEmpty(id))
			{
				return new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Invalid user ID");
			}
			var user = UserManager.FindById(id);
			if (user == null)
			{
				return new HttpStatusCodeResult(HttpStatusCode.NotFound, "User not found");
			}

			#endregion

			ViewBag.UserName = user.FirstName + " " + user.LastName;

			var model = new ResetPasswordViewModel
			{
				Email = user.Email,
				Code = UserManager.GeneratePasswordResetToken(id)
			};
            return View(model);
		}