当前位置: 首页>>代码示例>>C#>>正文


C# ForgotPasswordViewModel类代码示例

本文整理汇总了C#中ForgotPasswordViewModel的典型用法代码示例。如果您正苦于以下问题:C# ForgotPasswordViewModel类的具体用法?C# ForgotPasswordViewModel怎么用?C# ForgotPasswordViewModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ForgotPasswordViewModel类属于命名空间,在下文中一共展示了ForgotPasswordViewModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ForgotPassword

        public ActionResult ForgotPassword(ForgotPasswordViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    SetRequestURL(APIURL.APPLICANT_FORGOT_PASSWORD, Method.POST);
                    request.AddBody(model);
                    var response = rest.Execute(request);

                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        SetMessage("An instruction for resetting your password has been sent on your email.", MESSAGE_TYPE.INFO);
                        return RedirectToAction("ForgotPassword");
                    }
                    else
                    {
                        ModelState.AddModelError("", response.Content);
                    }

                }
            }
            catch (CustomException ex)
            {
                ModelState.AddModelError("", ex.Message);
            }

            return View(model);
        }
开发者ID:neiljc07,项目名称:VSEntityFramework,代码行数:29,代码来源:BaseController.cs

示例2: ForgotPassword

        public async Task<IActionResult> ForgotPassword(ForgotPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await _userManager.FindByNameAsync(model.Email);
                if (user == null || !(await _userManager.IsEmailConfirmedAsync(user)))
                {
                    // Don't reveal that the user does not exist or is not confirmed
                    return View("ForgotPasswordConfirmation");
                }

                // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=532713
                // Send an email with this link
                //var code = await _userManager.GeneratePasswordResetTokenAsync(user);
                //var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: HttpContext.Request.Scheme);
                //await _emailSender.SendEmailAsync(model.Email, "Reset Password",
                //   "Please reset your password by clicking here: <a href=\"" + callbackUrl + "\">link</a>");
                //return View("ForgotPasswordConfirmation");
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
开发者ID:julianls,项目名称:AspNetCoreAngular2,代码行数:23,代码来源:AccountController.cs

示例3: ForgotPassword

        public async Task<ActionResult> ForgotPassword(ForgotPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByNameAsync(model.Email);
                if (user == null || !(await UserManager.IsEmailConfirmedAsync(user.Id)))
                {
                    ModelState.AddModelError("", "El usuario no existe o no se ha confirmado.");
                    return View();
                }

                // Para obtener más información sobre cómo habilitar la confirmación de cuenta y el restablecimiento de contraseña, visite http://go.microsoft.com/fwlink/?LinkID=320771
                // Enviar correo electrónico con este vínculo
                // string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);
                // var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);		
                // await UserManager.SendEmailAsync(user.Id, "Restablecer contraseña", "Para restablecer la contraseña, haga clic <a href=\"" + callbackUrl + "\">aquí</a>");
                // return RedirectToAction("ForgotPasswordConfirmation", "Account");
            }

            // Si llegamos a este punto, es que se ha producido un error y volvemos a mostrar el formulario
            return View(model);
        }
开发者ID:esmar,项目名称:appWeb,代码行数:22,代码来源:AccountController.cs

示例4: ForgotPassword

        public async Task<ActionResult> ForgotPassword(ForgotPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByNameAsync(model.Email);
                if (user == null || !(await UserManager.IsEmailConfirmedAsync(user.Id)))
                {
                    ModelState.AddModelError("", "Der Benutzer ist nicht vorhanden oder wurde nicht bestätigt.");
                    return View();
                }

                // Weitere Informationen zum Aktivieren der Kontobestätigung und Kennwortzurücksetzung finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=320771".
                // E-Mail-Nachricht mit diesem Link senden
                // string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);
                // var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);		
                // await UserManager.SendEmailAsync(user.Id, "Kennwort zurücksetzen", "Bitte setzen Sie Ihr Kennwort zurück. Klicken Sie dazu <a href=\"" + callbackUrl + "\">hier</a>");
                // return RedirectToAction("ForgotPasswordConfirmation", "Account");
            }

            // Wurde dieser Punkt erreicht, ist ein Fehler aufgetreten; Formular erneut anzeigen.
            return View(model);
        }
开发者ID:GundlackFelixDEV,项目名称:ASP.NET_TUTS,代码行数:22,代码来源:AccountController.cs

示例5: ForgotPassword

        public async Task<ActionResult> ForgotPassword(ForgotPasswordViewModel model, string returnUrl)
        {
            ViewBag.ReturnUrl = returnUrl;

            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByEmailAsync(model.Email);
                if (user == null)
                    // Не показывать, что пользователь не существует или не подтвержден
                    return View("ForgotPasswordConfirmation");
                _logger.Trace($"User \"{user.UserName}\" send request to reset password.");

                //Дополнительные сведения о том, как включить подтверждение учетной записи и сброс пароля, см.по адресу: http://go.microsoft.com/fwlink/?LinkID=320771
                //Отправка сообщения электронной почты с этой ссылкой
                string token = await UserManager.GeneratePasswordResetTokenAsync(user.Id);
                var callbackUrl = Url.Action(nameof(ResetPassword), "Account", new { userId = user.Id, token }, protocol: Request.Url.Scheme);

                var emailModel = new
                {
                    UserName = user.UserName,
                    CallbackUrl = callbackUrl
                };

                string body = await EmailBodyServiceFactory.GetEmailBody(emailModel, "ForgotPassword");
                await UserManager.SendEmailAsync(user.Id, "Відновлення пароля", body);
                _logger.Debug($"Send verification email to {user.UserName} for reset password.");

                return View("ForgotPasswordConfirmation");
            }

            // Появление этого сообщения означает наличие ошибки; повторное отображение формы
            return View(model);
        }
开发者ID:inatoff,项目名称:ACTS_Site,代码行数:33,代码来源:AccountController.cs

示例6: ForgotPassword

        public async Task<ActionResult> ForgotPassword(ForgotPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByNameAsync(model.Email);
                if (user == null || !(await UserManager.IsEmailConfirmedAsync(user.Id)))
                {
                    // Don't reveal that the user does not exist or is not confirmed
                    return View("ForgotPasswordConfirmation");
                }

                // Send an email with this link
                string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);
                var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                await UserManager.SendEmailAsync(user.Id, "Reset Password", "Please reset your password by clicking <a href=\"" + callbackUrl + "\">here</a>");
                return RedirectToAction("ForgotPasswordConfirmation", "Account");
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
开发者ID:VladimirToth,项目名称:BluePumpkin,代码行数:21,代码来源:AccountController.cs

示例7: ForgotPassword

        public ActionResult ForgotPassword(ForgotPasswordViewModel model)
        {
            if (model == null) throw new ArgumentNullException("model");

            if (ModelState.IsValid)
            {
                string resetToken;
                try
                {
                    resetToken = WebSecurity.GeneratePasswordResetToken(model.Email);
                }
                catch (Exception)
                {
                    TempData["Message"] = "Пользователя с таким Email не существует.";
                    return View(model);
                }
                try
                {
                    EmailManager.SendForgotPasswordEmail(model.Email, @Url.Action("ResetPassword", "Account",
                                                                                  new {id = resetToken},
                                                                                  Request.Url != null
                                                                                      ? Request.Url.Scheme
                                                                                      : null));
                    TempData["Message"] =
                        "На ваш электронный ящик отправлено письмо с дальнейшими инструкциями по восстановлению пароля. "
                        + "Проверьте ваш электронный ящик.";
                }
                catch (Exception)
                {
                    TempData["Message"] = "Ошибка при отправке сообщения. Обратитесь к администратору.";
                }
            }
            return View(model);
        }
开发者ID:vitalzhuravkov,项目名称:FileUploader,代码行数:34,代码来源:AccountController.cs

示例8: ForgotPassword

		public async Task<IHttpActionResult> ForgotPassword(ForgotPasswordViewModel model) {
			if (!ModelState.IsValid) return BadRequest(ModelState);

			var user = await UserManager.FindByNameAsync(model.Email);
			if (user == null) {
				// Don't reveal that the user does not exist or is not confirmed
				ModelState.AddModelError("", "That user does not exist");
				return BadRequest(ModelState);
			}

			var code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);
			var callbackUrl = Utility.AbsoluteUrl("/ResetPassword?code="+HttpUtility.UrlEncode(code));
			await UserManager.SendEmailAsync(user.Id, "Reset Password", "Please reset your password by clicking here: <a href=\"" + callbackUrl + "\">link</a>");
			return Ok(new { message = "We've emailed you a link to reset your password!" });
		}
开发者ID:nitin27may,项目名称:MVC5-SPA-Angular,代码行数:15,代码来源:AccountController.cs

示例9: ForgotPassword

 public async Task<ActionResult> ForgotPassword(ForgotPasswordViewModel model)
 {
     if (ModelState.IsValid)
     {
         var user = await UserManager.FindByNameAsync(model.Email);
         if (user != null && !(await UserManager.IsEmailConfirmedAsync(user.Id)))
         {
             try
             {
                 string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);
                 var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                 MailManager.sendPasswordResetEmail("Reset Password", "Please reset your password by clicking <a href=\"" + callbackUrl + "\">here</a>", user.Email);
                 return View("ForgotPasswordConfirmation");
             }
             catch (Exception)
             {
                 ModelState.AddModelError("", "Please! Try again.");
                 return View(model);
             }
         }
         else
         {
             ModelState.AddModelError("", "User does not exist.");
             return View(model);
         }
     }
     return View(model);
 }
开发者ID:uzmaha,项目名称:Development-GitHub,代码行数:28,代码来源:AccountController.cs

示例10: ForgotPassword

        public async Task<ActionResult> ForgotPassword(ForgotPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await _userManager.FindByEmailAsync(model.Email);
                if (user == null || !(await _userManager.IsEmailConfirmedAsync(user.Id)))
                {
                    // Don't reveal that the user does not exist or is not confirmed
                    return View("ForgotPasswordConfirmation");
                }

                var code = await _userManager.GeneratePasswordResetTokenAsync(user.Id);
                var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);

                string subject = IdentityResourceHelper.Load(IdentitySettings.IdentityResource, "Notify_ForgotPassword_Subject");
                string bodyFormatString = IdentityResourceHelper.Load(IdentitySettings.IdentityResource, "Notify_ForgotPassword_Body");
                string body = string.Format(bodyFormatString, callbackUrl);
                await _userManager.SendEmailAsync(user.Id, subject, body);

                return View("ForgotPasswordConfirmation");
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
开发者ID:RodionKulin,项目名称:ContentManagementBackend,代码行数:25,代码来源:AccountController.cs

示例11: ForgotPassword

        public async Task<IActionResult> ForgotPassword(ForgotPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await _userManager.FindByNameAsync(model.Email);
                if (user == null || !(await _userManager.IsEmailConfirmedAsync(user)))
                {
                    // Don't reveal that the user does not exist or is not confirmed
                    return View("ForgotPasswordConfirmation");
                }

                // Send an email with this link
                var code = await _userManager.GeneratePasswordResetTokenAsync(user);
                var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code }, Request.Scheme);

                var message = new AuthMessageSender.Message
                {
                    Subject = "Reset Password",
                    Body = "Please reset your password by clicking:  <a href='" + callbackUrl + "'>this link</a>"
                };

                await _emailSender.SendEmailAsync(model.Email, message.Subject, message.Body, _userEmailAccount,
                    _userEmailPassword);

                return View("ForgotPasswordConfirmation");
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
开发者ID:lumalav,项目名称:3DCytoFlowMVC6,代码行数:30,代码来源:AccountController.cs

示例12: ForgotPassword

        public async Task<IHttpActionResult> ForgotPassword(ForgotPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByNameAsync(model.Email);
                if (user == null)
                {
                    // Don't reveal that the user does not exist or is not confirmed
                    return Ok();
                }

                string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);
                string urlencoded = HttpUtility.UrlEncode(code);
                //var callbackUrl = Url.Route("ResetPassword", new { userId = user.Id, code = code });
                var callbackUrl = "http://" + ConfigurationManager.AppSettings["Server"] + "/resetpassword/resetpassword/forgotpassword?userId=" + user.Id + "&Code=" + urlencoded;
                await UserManager.SendEmailAsync(user.Id, "Reset Password",
                   "Please reset your password by clicking <a href=\"" + callbackUrl + "\">here</a>");
                return Ok();
            }
            else
            {
                return BadRequest(ModelState);
            }
        }
开发者ID:AGSoftwareInc,项目名称:Storytime,代码行数:24,代码来源:AccountController.cs

示例13: ForgotPassword

        public async Task<ActionResult> ForgotPassword(ForgotPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByNameAsync(model.Email);
                if (user == null || !(await UserManager.IsEmailConfirmedAsync(user.Id)))
                {
                    ModelState.AddModelError("", "用户不存在或未确认。");
                    return View();
                }

                // 有关如何启用帐户确认和密码重置的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkID=320771
                // 发送包含此链接的电子邮件
                // string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);
                // var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);		
                // await UserManager.SendEmailAsync(user.Id, "重置密码", "请通过单击 <a href=\"" + callbackUrl + "\">此处</a>来重置你的密码");
                // return RedirectToAction("ForgotPasswordConfirmation", "Account");
            }

            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            return View(model);
        }
开发者ID:K-Library-NET,项目名称:PopcornStudios,代码行数:22,代码来源:AccountController.cs

示例14: ForgotPassword

    public async Task<IActionResult> ForgotPassword(ForgotPasswordViewModel model)
    {
      if (ModelState.IsValid)
      {
        var user = await _userManager.FindByNameAsync(model.Email);
        if (user == null || !(await _userManager.IsEmailConfirmedAsync(user)))
        {
          // Don't reveal that the user does not exist or is not confirmed
          return View("ForgotPasswordConfirmation");
        }

        //Send an email with this link
        var code = await _userManager.GeneratePasswordResetTokenAsync(user);
        var callbackUrl = Url.Action(new UrlActionContext
        {
          Action = nameof(ResetPassword),
          Controller = "Account",
          Values = new { userId = user.Id, code = code },
          Protocol = HttpContext.Request.Scheme
        });
        await _emailSender.SendEmailAsync(model.Email, "Reset allReady Password", $"Please reset your allReady password by clicking here: <a href=\"{callbackUrl}\">link</a>");

        return View("ForgotPasswordConfirmation");
      }

      // If we got this far, something failed, redisplay form
      return View(model);
    }
开发者ID:shawnwildermuth,项目名称:allReady,代码行数:28,代码来源:AccountController.cs

示例15: ajax_ForgotPassword

        public async Task<string> ajax_ForgotPassword(ForgotPasswordViewModel model)
        {
            ResultInfo rAjaxResult = new ResultInfo();

            try
            {
                if (ModelState.IsValid)
                {
                    var user = await UserManager.FindByEmailAsync(model.Email);
                    //2014-5-20 Jerry 目前本系統不作Email驗證工作
                    //if (user == null || !(await UserManager.IsEmailConfirmedAsync(user.Id)))
                    if (user == null)
                        throw new Exception(Resources.Res.Login_Err_Password);

                    string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);
                    var callbackUrl = Url.Action("ResetPassword", "MNGLogin", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    await UserManager.SendEmailAsync(user.Id, "重設密碼", "請按 <a href=\"" + callbackUrl + "\">這裏</a> 重設密碼");

                    rAjaxResult.result = true;
                }
                else
                {
                    List<string> errMessage = new List<string>();
                    foreach (ModelState modelState in ModelState.Values)
                        foreach (ModelError error in modelState.Errors)
                            errMessage.Add(error.ErrorMessage);

                    rAjaxResult.message = String.Join(":", errMessage);
                    rAjaxResult.result = false;
                }
            }
            catch (Exception ex)
            {
                rAjaxResult.result = false;
                rAjaxResult.message = ex.Message;
            }

            return defJSON(rAjaxResult);
        }
开发者ID:jcingroup,项目名称:C501602_ATEK,代码行数:39,代码来源:LoginController.cs


注:本文中的ForgotPasswordViewModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。