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


C# UserManager.GeneratePasswordResetToken方法代码示例

本文整理汇总了C#中UserManager.GeneratePasswordResetToken方法的典型用法代码示例。如果您正苦于以下问题:C# UserManager.GeneratePasswordResetToken方法的具体用法?C# UserManager.GeneratePasswordResetToken怎么用?C# UserManager.GeneratePasswordResetToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserManager的用法示例。


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

示例1: ForgotPassword

        public ActionResult ForgotPassword(string email)
        {
            var userStore = new UserStore<IdentityUser>();
            UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
            var user = manager.FindByEmail(email);
            CreateTokenProvider(manager, PASSWORD_RESET);

            var code = manager.GeneratePasswordResetToken(user.Id);
            var callbackUrl = Url.Action("ResetPassword", "Home",
                                         new { userId = user.Id, code = code },
                                         protocol: Request.Url.Scheme);
            ViewBag.FakeEmailMessage = "Please reset your password by clicking <a href=\""
                                     + callbackUrl + "\">here</a>";
            return View();
        }
开发者ID:cj8397,项目名称:2hourVer2,代码行数:15,代码来源:HomeController.cs

示例2: ForgotPassword

        public ActionResult ForgotPassword(string email, RegisteredUser userRecovery)
        {
            var userStore = new UserStore<IdentityUser>();
            UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
            var user = manager.FindByEmail(email);
            CreateTokenProvider(manager, PASSWORD_RESET);

            var code = manager.GeneratePasswordResetToken(user.Id);
            var callbackUrl = Url.Action("ResetPassword", "Accounts",
                                         new { userId = user.Id, code = code },
                                         protocol: Request.Url.Scheme);
            var body = "Please reset your password by clicking <a href=\""
                                     + callbackUrl + "\">here</a>";

            MailHelper mailer = new MailHelper();
            string response = mailer.EmailFromArvixe(
                                       new RegisteredUser(userRecovery.Email = email, userRecovery.Subject = "Password Recovery Email", userRecovery.Body = body));
            return View("PasswordEmail");
        }
开发者ID:kpawa,项目名称:Jarvis,代码行数:19,代码来源:AccountsController.cs

示例3: ForgotPassword

        public ActionResult ForgotPassword(string email)
        {
            var userStore = new UserStore<IdentityUser>();
            UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
            var user = manager.FindByEmail(email);
            CreateTokenProvider(manager, PASSWORD_RESET);

            if (user != null)
            {

                var code = manager.GeneratePasswordResetToken(user.Id);
                string callbackUrl = Url.Action("ResetPassword", "Home",
                                             new { userId = user.Id, code = code },
                                             protocol: Request.Url.Scheme);
                string emailMessage = "Please reset your password by clicking <a href=\""
                                         + callbackUrl + "\">here</a>";

                string response = new MailHelper().EmailFromArvixe(new ViewModels.Message(email, emailMessage));

                ViewBag.FakeEmailMessage = "Email successfully sent. Please check your email to reset your password";

                return View();
            }

            ViewBag.Error = "There wasn't an account for that email";
            return View();
        }
开发者ID:andrewstec,项目名称:phase2_lastday,代码行数:27,代码来源:HomeController.cs

示例4: ForgotPassword

        public ActionResult ForgotPassword(string email)
        {
            //ensures valid input
            if (ModelState.IsValid)
            {
                CaptchaHelper captchaHelper = new CaptchaHelper();
                string captchaResponse = captchaHelper.CheckRecaptcha();
                ViewBag.CaptchaResponse = captchaResponse;

                //creates token to be sent to mail helper to allow password reset through email
                var userStore = new UserStore<IdentityUser>();
                UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
                var user = manager.FindByEmail(email);
                CreateToken ct = new CreateToken();
                CreateTokenProvider(manager, PASSWORD_RESET);

                var code = manager.GeneratePasswordResetToken(user.Id);
                var callbackUrl = Url.Action("ResetPassword", "Home",
                                             new { userId = user.Id, code = code },
                                             protocol: Request.Url.Scheme);

                //send callbackUrl to email helper
                MailHelper mailer = new MailHelper();
                string message = "Please reset your password by clicking <a href=\""
                                         + callbackUrl + "\">here</a>";
                string subject = "Please reset your password";
                try
                {
                    mailer.EmailFromArvixe(message, user.Email, subject);
                    ViewBag.FakeEmailMessage =
                        "You have been sent an email to finish reseting your password";
                }
                catch (System.Exception ex)
                {
                    ViewBag.FakeEmailMessage = ex.Message;
                }
            }
            return View();
        }
开发者ID:snew1,项目名称:sampleAccountCreation,代码行数:39,代码来源:HomeController.cs

示例5: ForgotPassword

        public ActionResult ForgotPassword(string email)
        {

            CaptchaHelper captchaHelper = new CaptchaHelper();
            string captchaResponse = captchaHelper.CheckRecaptcha();
            ViewBag.CaptchaResponse = captchaResponse;
            if (captchaResponse == VALID_CAPTCHA)
            {
                var userStore = new UserStore<IdentityUser>();
                UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
                var user = manager.FindByEmail(email);
                CreateTokenProvider(manager, PASSWORD_RESET);
                var code = manager.GeneratePasswordResetToken(user.Id);
                var callbackUrl = Url.Action("ResetPassword", "Home",
                                             new { userId = user.Id, code = code },
                                             protocol: Request.Url.Scheme);
                var emailMsg = "<h3>Please reset your password by clicking</h3> <a href=\""
                                         + callbackUrl + "\">This Link</a>";
                MailHelper mailer = new MailHelper();
                string response = mailer.EmailFromArvixe(new RegisteredUser { Email = user.Email, UserName = user.UserName }, emailMsg);
                ViewBag.Response = response;
                TempData["response"] = response;
                return RedirectToAction("Index", "Home");
            }
            return View();
        }
开发者ID:Mariocf93,项目名称:WebSecurity,代码行数:26,代码来源:HomeController.cs

示例6: EmailConfirmationToken

 public void EmailConfirmationToken()
 {
     var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(this._session));
     userManager.UserTokenProvider = new EmailTokenProvider<ApplicationUser, string>() { BodyFormat = "xxxx {0}", Subject = "Reset password" };
     userManager.Create(new ApplicationUser() { UserName = "test", Email = "[email protected]", EmailConfirmed = false }, "Welcome");
     var x = userManager.FindByEmail("[email protected]");
     string token = userManager.GeneratePasswordResetToken(x.Id);
     userManager.ResetPassword(x.Id, token, "Welcome!");
 }
开发者ID:dags20,项目名称:NHibernate.AspNet.Identity.MultiTenant,代码行数:9,代码来源:UserStoreTest.cs

示例7: ForgotPassword

        public ActionResult ForgotPassword(string email)
        {
            var userStore = new UserStore<IdentityUser>();
            UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
            var user = manager.FindByEmail(email);
            CreateTokenProvider(manager, PASSWORD_RESET);

            var code = manager.GeneratePasswordResetToken(user.Id);
            var callbackUrl = Url.Action("ResetPassword", "Account",
                                         new { userId = user.Id, code = code },
                                         protocol: Request.Url.Scheme);
            string link = "Please reset your password by clicking <a href=\""
                                     + callbackUrl + "\">here</a>";


            MailHelper mailer = new MailHelper();
            string response = mailer.EmailFromArvixe(
                                       new RegisteredUser(email, PASSWORD_RESET, link));
            if (response != "Failure sending mail.")
            {
                ViewBag.Success = response;
            }
            else {
                ViewBag.Failure = response;
            }

            return View();
        }
开发者ID:cj8397,项目名称:2hourVer2,代码行数:28,代码来源:AccountController.cs

示例8: ForgotPassword

        public ActionResult ForgotPassword(string email)
        {
            var userStore = new UserStore<IdentityUser>();
            UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
            var user = manager.FindByEmail(email);

            if (user == null)
            {
                ViewBag.Message = "Email not found. Please double-check and try again.";
                return View();
            }
            CreateTokenProvider(manager, PASSWORD_RESET);

            var code = manager.GeneratePasswordResetToken(user.Id);
            var callbackUrl = Url.Action("ResetPassword", "Home",
                                         new { userId = user.Id, code = code },
                                         protocol: Request.Url.Scheme);

            string emailBody = "Please reset your password by clicking <a href=\""
                                     + callbackUrl + "\">here</a>";

            MailHelper mailer = new MailHelper();

            string Subject = "Confirm password reset";
            string response = mailer.EmailFromArvixe(
                                       new Message(user.Email, Subject, emailBody));

            if (response.IndexOf("Success") >= 0)
            {
                ViewBag.Message = "A confirm email has been sent. Please check your your email.";
                ViewBag.Email = user.Email;
            }
            else
            {
                ViewBag.Message = response;
            }
            return View();
        }
开发者ID:rachelyu0102,项目名称:dating-project-ssd,代码行数:38,代码来源:HomeController.cs


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