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


C# UserManager.ResetPassword方法代码示例

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


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

示例1: ResetPassword

        public ActionResult ResetPassword(string password, string passwordConfirm,
                                          string passwordToken, string userID)
        {

            var userStore = new UserStore<IdentityUser>();
            UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
            var user = manager.FindById(userID);
            CreateTokenProvider(manager, PASSWORD_RESET);

            IdentityResult result = manager.ResetPassword(userID, passwordToken, password);
            if (result.Succeeded)
                ViewBag.Result = "The password has been reset.";
            else
                ViewBag.Result = "The password has not been reset.";
            return View();
        }
开发者ID:cj8397,项目名称:2hourVer2,代码行数:16,代码来源:HomeController.cs

示例2: 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

示例3: ResetPassword

        public ActionResult ResetPassword(string password, string passwordConfirm,
                                          string passwordToken, string userID)
        {
            //called from email link, receives token and allows user to change password
            var userStore = new UserStore<IdentityUser>();
            UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
            var user = manager.FindById(userID);
            CreateToken ct = new CreateToken();
            CreateTokenProvider(manager, PASSWORD_RESET);

            IdentityResult result = manager.ResetPassword(userID, passwordToken, password);
            if (result.Succeeded)
                ViewBag.Result = "The password has been reset.";
            else
                ViewBag.Result = "The password has not been reset.";
            return View();
        }
开发者ID:snew1,项目名称:sampleAccountCreation,代码行数:17,代码来源:HomeController.cs

示例4: ResetPassword

        public ActionResult ResetPassword(ResetPassword resetPassword,
                                          string passwordToken, string userID)
        {
            if (ModelState.IsValid)
            {
                var userStore = new UserStore<IdentityUser>();
                UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
                var user = manager.FindById(userID);
                CreateTokenProvider(manager, PASSWORD_RESET);

                IdentityResult result = manager.ResetPassword(userID, passwordToken, resetPassword.Password);
                if (result.Succeeded)
                {
                    TempData["Message"] = "The password has been reset. Please login in";
                    return RedirectToAction("Index");
                }
                else {
                    ViewBag.Message = "The password has not been reset.";
                }
            }
            else
            {
                ViewBag.Message = "Passworld reset failed. Please make sure password combine alphabet letter and numbers.";
            }

            return View();
        }
开发者ID:rachelyu0102,项目名称:dating-project-ssd,代码行数:27,代码来源:HomeController.cs


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