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


C# UserStore.SetPasswordHashAsync方法代码示例

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


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

示例1: SetPasswordHashAsync_GivenAUserAndPasswordHash_SetsTheHashForTheUser

        public async void SetPasswordHashAsync_GivenAUserAndPasswordHash_SetsTheHashForTheUser()
        {
            var applicationDatabaseConfiguration = new ApplicationDatabaseConfiguration();
            var userStore = new UserStore<User>(applicationDatabaseConfiguration);

            var user = new User
            {
                Email = "[email protected]",
                IsEmailConfirmed = true,
                PasswordHash = "PasswordHash",
                PhoneNumber = "PhoneNumber",
                IsPhoneNumberConfirmed = true,
                IsTwoFactorEnabled = false,
                LockoutEndDateUtc = null,
                IsLockoutEnabled = true,
                AccessFailedCount = 0,
                UserName = "UserName",
                IsAccountActive = true
            };

            await userStore.CreateAsync(user);

            await userStore.SetPasswordHashAsync(user, "1234");

            var passwordHash = await userStore.GetPasswordHashAsync(user);

            passwordHash.Should().Be("1234");
        }
开发者ID:raypigott,项目名称:Identity,代码行数:28,代码来源:UserPasswordStoreTests.cs

示例2: Button1_Click

 protected async void Button1_Click(object sender, EventArgs e)
 {
     if (txtPsw.Text.Length > 8)
     {
     UserStore<ApplicationUser> store = new UserStore<ApplicationUser>(_db);
     UserManager<ApplicationUser> UserManager = new UserManager<ApplicationUser>(store);
     String userId = ddlUser.SelectedValue.ToString(); 
     String newPassword = txtPsw.Text; 
     String hashedNewPassword = UserManager.PasswordHasher.HashPassword(newPassword);
     ApplicationUser cUser = await store.FindByIdAsync(userId);
     await store.SetPasswordHashAsync(cUser, hashedNewPassword);
     await store.UpdateAsync(cUser);
         lblOk.ForeColor = Color.GreenYellow;
         lblOk.Text = "Password modificata con successo!";
     }
     else
     {
         lblOk.ForeColor = Color.Red;
         lblOk.Text = "Scrivi una password valida! Almeno 8 carattteri, 1 maiuscola e un carattere non alfanumerico!";
     }
 }
开发者ID:alceweb,项目名称:PuntoFitness2,代码行数:21,代码来源:rst.aspx.cs

示例3: ChangeUserData

        public void ChangeUserData(UserdataChangeModel model, IdentityUser user)
        {
            String hashedNewPassword = _userManager.PasswordHasher.HashPassword(model.password);
            UserStore<IdentityUser> store = new UserStore<IdentityUser>(context);
            store.SetPasswordHashAsync(user, hashedNewPassword);
            store.UpdateAsync(user);

            UserInfos info = (from m in db.UserInfos
                             where m.User_FK == user.Id
                             select m).First<UserInfos>();

            if (model.firstname != null)
                info.firstname = model.firstname;

            if (model.lastname != null)
                info.lastname = model.lastname;

            db.Entry(info).State = EntityState.Modified;

            db.SaveChanges();

        }
开发者ID:abarathUCLAN,项目名称:Asp.Net-Web-Api,代码行数:22,代码来源:UserRepository.cs

示例4: ResetPasswords

        public async Task<ActionResult> ResetPasswords()
        {
            SkyberryContext context = new SkyberryContext();
            UserStore<SkyberryUser> store = new UserStore<SkyberryUser>(context);
            UserManager<SkyberryUser> UserManager = new UserManager<SkyberryUser>(store);
            var RoleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(context));

            var cUsers = UserManager.Users.ToList();

            foreach (var cUser in cUsers)
            {
                String hashedNewPassword = UserManager.PasswordHasher.HashPassword(cUser.OldPassword ?? "p4ssL3tt3rs");
                await store.SetPasswordHashAsync(cUser, hashedNewPassword);
                await store.UpdateAsync(cUser);
            }


            if (!RoleManager.RoleExists("Admin"))
            {
                var adminIR = RoleManager.Create(new IdentityRole("Admin"));
            }

            if (!RoleManager.RoleExists("Client"))
            {
                var clientIR = RoleManager.Create(new IdentityRole("Client"));
            }

            foreach (SkyberryUser user in UserManager.Users.ToList())
            {
                UserManager.AddToRole(user.Id, "Client");
                if (user.UserName == "daniel" || user.UserName == "lacey")
                {
                    UserManager.AddToRole(user.Id, "Admin");
                }
            }

            return View();
        }
开发者ID:daniel-williams,项目名称:skyberry2016,代码行数:38,代码来源:AdminController.cs

示例5: ResetPassword

        public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model, String id)
        {
            ApplicationDbContext context = new ApplicationDbContext();

            UserStore<ApplicationUser> store = new UserStore<ApplicationUser>(context);

            UserManager<ApplicationUser> UserManager = new UserManager<ApplicationUser>(store);

            String hashedNewPassword = UserManager.PasswordHasher.HashPassword(model.Password);

            ApplicationUser cUser = await store.FindByIdAsync(id);

            await store.SetPasswordHashAsync(cUser, hashedNewPassword);
            await store.UpdateAsync(cUser);

            return RedirectToAction("Index");
        }
开发者ID:timnicolaisen,项目名称:eule,代码行数:17,代码来源:EmployeeController.cs

示例6: UserStorePublicNullCheckTest

 public void UserStorePublicNullCheckTest()
 {
     var store = new UserStore<IdentityUser>();
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.CreateAsync(null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.UpdateAsync(null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.DeleteAsync(null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.AddClaimAsync(null, null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.RemoveClaimAsync(null, null)),
         "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetClaimsAsync(null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetLoginsAsync(null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetRolesAsync(null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.AddLoginAsync(null, null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.RemoveLoginAsync(null, null)),
         "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.AddToRoleAsync(null, null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.RemoveFromRoleAsync(null, null)),
         "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.IsInRoleAsync(null, null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetPasswordHashAsync(null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.SetPasswordHashAsync(null, null)),
         "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetSecurityStampAsync(null)),
         "user");
     ExceptionHelper.ThrowsArgumentNull(
         () => AsyncHelper.RunSync(() => store.SetSecurityStampAsync(null, null)), "user");
     ExceptionHelper.ThrowsArgumentNull(
         () => AsyncHelper.RunSync(() => store.AddClaimAsync(new IdentityUser("fake"), null)), "claim");
     ExceptionHelper.ThrowsArgumentNull(
         () => AsyncHelper.RunSync(() => store.RemoveClaimAsync(new IdentityUser("fake"), null)), "claim");
     ExceptionHelper.ThrowsArgumentNull(
         () => AsyncHelper.RunSync(() => store.AddLoginAsync(new IdentityUser("fake"), null)), "login");
     ExceptionHelper.ThrowsArgumentNull(
         () => AsyncHelper.RunSync(() => store.RemoveLoginAsync(new IdentityUser("fake"), null)), "login");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.FindAsync(null)), "login");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetEmailConfirmedAsync(null)),
         "user");
     ExceptionHelper.ThrowsArgumentNull(
         () => AsyncHelper.RunSync(() => store.SetEmailConfirmedAsync(null, true)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetEmailAsync(null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.SetEmailAsync(null, null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetPhoneNumberAsync(null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.SetPhoneNumberAsync(null, null)),
         "user");
     ExceptionHelper.ThrowsArgumentNull(
         () => AsyncHelper.RunSync(() => store.GetPhoneNumberConfirmedAsync(null)), "user");
     ExceptionHelper.ThrowsArgumentNull(
         () => AsyncHelper.RunSync(() => store.SetPhoneNumberConfirmedAsync(null, true)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetTwoFactorEnabledAsync(null)),
         "user");
     ExceptionHelper.ThrowsArgumentNull(
         () => AsyncHelper.RunSync(() => store.SetTwoFactorEnabledAsync(null, true)), "user");
     ExceptionHelper.ThrowsArgumentNullOrEmpty(
         () => AsyncHelper.RunSync(() => store.AddToRoleAsync(new IdentityUser("fake"), null)), "roleName");
     ExceptionHelper.ThrowsArgumentNullOrEmpty(
         () => AsyncHelper.RunSync(() => store.RemoveFromRoleAsync(new IdentityUser("fake"), null)), "roleName");
     ExceptionHelper.ThrowsArgumentNullOrEmpty(
         () => AsyncHelper.RunSync(() => store.IsInRoleAsync(new IdentityUser("fake"), null)), "roleName");
 }
开发者ID:tomi85,项目名称:aspnetidentity,代码行数:59,代码来源:UserStoreTest.cs

示例7: RecoverPassword

        public async Task<ActionResult> RecoverPassword(PasswordRecoveryModel model)
        {
            if (ModelState.IsValid)
            {
                if (string.IsNullOrEmpty(model.InputAnswer))
                {
                    // begin recaptcha helper setup
                    var recaptchaHelper = this.GetRecaptchaVerificationHelper();

                    if (String.IsNullOrEmpty(recaptchaHelper.Response))
                    {
                        ModelState.AddModelError("", "Captcha answer cannot be empty");
                        return View(model);
                    }

                    var recaptchaResult = recaptchaHelper.VerifyRecaptchaResponse();

                    if (recaptchaResult != RecaptchaVerificationResult.Success)
                    {
                        ModelState.AddModelError("", "Incorrect captcha answer");
                        return View(model);
                    }
                    // end recaptcha helper setup

                    // Find username and pass it along
                    var user = await UserManager.FindByNameAsync(model.UserName);
                    if (user == null)
                        return View(model);
                    if (string.IsNullOrEmpty(user.RecoveryQuestion))
                    {
                        ModelState.AddModelError("", string.Format("{0} does not have a question to answer therefore no password recovery can be attempted.", model.UserName));
                        return View(model);
                    }
                    ViewBag.HasUsername = true;
                    model.UserName = user.UserName;
                    ViewBag.Username = user.UserName;
                    model.Question = user.RecoveryQuestion;
                }
                else
                {
                    var username = model.UserName;
                    if (username == null)
                        username = ViewBag.Username;
                    if (string.IsNullOrEmpty(model.InputAnswer) ||
                        string.IsNullOrEmpty(username) ||
                        string.IsNullOrEmpty(model.Question))
                    {
                        ModelState.AddModelError("", "Something went wrong!");
                        return View(model);
                    }
                    var user = await UserManager.FindByNameAsync(username);

                    if (user == null)
                    {
                        ModelState.AddModelError("", "Something went wrong!");
                        return View(model);
                    }

                    if (user.RecoveryQuestion != model.Question ||
                        user.Answer.ToLower() != model.InputAnswer.ToLower())
                    {
                        ModelState.AddModelError("", "Invalid answer.");
                        return View(model);
                    }
                    var newPassHash = UserManager.PasswordHasher.HashPassword(model.Password);
                    ApplicationUser cUser = UserManager.FindById(user.Id);
                    UserStore<ApplicationUser> store = new UserStore<ApplicationUser>();
                    await store.SetPasswordHashAsync(cUser, newPassHash);
                    await store.UpdateAsync(cUser);
                }
            }

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

示例8: When_User_Does_Not_Exist_SetPasswordHashAsync_Fails

        public async void When_User_Does_Not_Exist_SetPasswordHashAsync_Fails()
        {
            var user = new IdentityUser("foo");
            var passwordHash = "somepasswordhash";

            var mockResult = new Mock<IOperationResult<IdentityUser>>();
            mockResult.SetupGet(x => x.Success).Returns(false);
            mockResult.SetupGet(x => x.Status).Returns(ResponseStatus.KeyNotFound);

            var mockBucket = new Mock<IBucket>();
            mockBucket.SetupGet(e => e.Name).Returns("default");
            mockBucket.Setup(x => x.ReplaceAsync(It.IsAny<string>(), It.IsAny<IdentityUser>()))
                .ReturnsAsync(mockResult.Object);

            var store = new UserStore<IdentityUser>(new ThrowableBucket(mockBucket.Object));
            await store.SetPasswordHashAsync(user, passwordHash);
            Assert.Throws<CouchbaseException>(async () => await store.UpdateAsync(user));
        }
开发者ID:RoyGoode,项目名称:couchbase-aspnet-identity,代码行数:18,代码来源:UserStoreTests.cs

示例9: When_User_Exists_SetPasswordHashAsync_Succeeds

        public void When_User_Exists_SetPasswordHashAsync_Succeeds()
        {
            var user = new IdentityUser("foo");
            const string passwordHash = "somepasswordhash";

            var mockResult = new Mock<IOperationResult<IdentityUser>>();
            mockResult.SetupGet(x => x.Success).Returns(true);
            mockResult.SetupGet(x => x.Status).Returns(ResponseStatus.Success);

            var mockBucket = new Mock<IBucket>();
            mockBucket.SetupGet(e => e.Name).Returns("default");
            mockBucket.Setup(x => x.ReplaceAsync(It.IsAny<string>(), It.IsAny<IdentityUser>()))
                .ReturnsAsync(mockResult.Object);

            var store = new UserStore<IdentityUser>(new ThrowableBucket(mockBucket.Object));
            Assert.DoesNotThrow(async () => await store.SetPasswordHashAsync(user, passwordHash));
            Assert.AreEqual(passwordHash, user.PasswordHash);
        }
开发者ID:RoyGoode,项目名称:couchbase-aspnet-identity,代码行数:18,代码来源:UserStoreTests.cs

示例10: PasswordHash

        public void PasswordHash()
        {
            using (UserStore<IdentityUser> store = new UserStore<IdentityUser>())
            {
                using (UserManager<IdentityUser> manager = new UserManager<IdentityUser>(store))
                {
                    var user = User;
                    string passwordPlain = Guid.NewGuid().ToString("N");
                    string passwordHash = manager.PasswordHasher.HashPassword(passwordPlain);

                    var taskUserSet = store.SetPasswordHashAsync(user, passwordHash);
                    taskUserSet.Wait();

                    var taskHasHash = manager.HasPasswordAsync(user.Id);
                    taskHasHash.Wait();
                    Assert.IsTrue(taskHasHash.Result, "PasswordHash not set");

                    var taskUser = store.GetPasswordHashAsync(user);
                    taskUser.Wait();
                    Assert.AreEqual<string>(passwordHash, taskUser.Result, "PasswordHash not equal");
                    user.PasswordHash = passwordHash;
                    try
                    {
                        var task = store.GetPasswordHashAsync(null);
                        task.Wait();
                    }
                    catch (Exception ex)
                    {
                        Assert.IsNotNull(ex, "Argument exception not raised");
                    }

                    try
                    {
                        var task = store.HasPasswordAsync(null);
                        task.Wait();
                    }
                    catch (Exception ex)
                    {
                        Assert.IsNotNull(ex, "Argument exception not raised");
                    }

                    try
                    {
                        var task = store.SetPasswordHashAsync(null, passwordHash);
                        task.Wait();
                    }
                    catch (Exception ex)
                    {
                        Assert.IsNotNull(ex, "Argument exception not raised");
                    }

                    try
                    {
                        var task = store.SetPasswordHashAsync(user, null);
                        task.Wait();
                    }
                    catch (Exception ex)
                    {
                        Assert.IsNotNull(ex, "Argument exception not raised");
                    }
                }
            }
        }
开发者ID:thermous,项目名称:identitydocumentdb,代码行数:63,代码来源:UserStoreTests.Properties.partial.cs

示例11: ResetPassword

        public async Task<ActionResult> ResetPassword(int id) {
            var familyUser = await _db.Users.Where(
                u => u.Claims.Any(c => c.ClaimType == "Family" && c.ClaimValue == id.ToString())
                ).FirstAsync();

            using (var userStore = new UserStore<WishlistUser>(_db))
            using (var userManager = new WishlistUserManager(userStore)) {
                var password = GenerateRandomPassword(8);
                var hashedPassword = userManager.PasswordHasher.HashPassword(password);
                await userStore.SetPasswordHashAsync(familyUser, hashedPassword);
                await userStore.UpdateAsync(familyUser);

                TempData["familyCredentials"] = new FamilyCredentials {
                    Username = familyUser.UserName,
                    Password = password
                };
                return RedirectToAction("Administer", new { id = id });
            }
        }
开发者ID:CapstoneWishlist,项目名称:Capstone_Wishlist_app,代码行数:19,代码来源:FamilyController.cs

示例12: ResetPassword

        public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model)
        {
            ajaxReturnData data = new ajaxReturnData();

            if (!ModelState.IsValid)
            {
                data.statusCode = data.statusCode = (int)statusCodes.fail;
                data.message = "either the email or passwords are wrong; password not reset";
            }
            else
            {
                try {
                    using (ApplicationDbContext DB = new ApplicationDbContext())
                    {

                        ApplicationUser user = new ApplicationUser();

                        var store = new UserStore<ApplicationUser>(DB);
                        UserManager<ApplicationUser> um = new UserManager<ApplicationUser>(store);
                        user = um.FindByEmail(model.Email);
                        PasswordHasher ph = new PasswordHasher();
                        await store.SetPasswordHashAsync(user, ph.HashPassword(model.Password));
                        await store.UpdateAsync(user);
                        data.statusCode = data.statusCode = (int)statusCodes.success;
                        data.message = "The for '"+model.Email+"' password has been reset";

                    }
                }
                catch(Exception ex)
                {
                    data.statusCode = data.statusCode = (int)statusCodes.fail;
                    data.message = "Well something broke...  "+ex.Message;
                }

                

            }

            return Json(data);
             
            //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("ResetPasswordConfirmation", "Account");
            //}
            //AddErrors(result);
            //return View();
        }
开发者ID:GoGoNihon,项目名称:nihonMVC,代码行数:54,代码来源:AccountController.cs

示例13: Edit

        public async Task<ActionResult> Edit(EditViewModel model)
        {
            try
            {
                if (_userManager.FindByName(model.UserName) != null)
                {

                    if (model.GroupVal != null)
                    {
                        var group = _repository.Find<Group>(Guid.Parse(model.GroupVal));

                        var userData = _userManager.FindById(model.Id);
                        TempData["firstname"] =userData.FirstName;
                        TempData["lastname"] = userData.LastName;
                        TempData["group"] = userData.GroupId;
                        TempData["country"] = userData.Country;
                        TempData["company"] = userData.Company;
                        TempData["alternatenumber"] = userData.AlternateNumber;
                        TempData["phnenumber"] = userData.PhoneNumber;
                        TempData["email"] = userData.Email;
                        TempData["id"] = userData.IdentificationNumber;




                        var userEdit = _userManager.FindById(model.Id);
                        userEdit.UserName = model.UserName.ToLower();
                        userEdit.PasswordHash = model.UserName.ToLower() + "1234";
                        String hashedNewPassword = _userManager.PasswordHasher.HashPassword(userEdit.PasswordHash);
                        userEdit.EditDateTime = DateTime.Now;
                        userEdit.Maker = User.Identity.GetUserName();
                        userEdit.FirstName = model.Firstname;
                        userEdit.LastName = model.Lastname;
                        userEdit.GroupId = group.Id;
                        userEdit.Country = model.Country;
                        userEdit.Company = model.Company;
                        userEdit.AlternateNumber = model.AlternateNumber;
                        userEdit.PhoneNumber = model.PhoneNumber;
                        userEdit.Email = model.Email;
                        userEdit.IdentificationNumber = model.IdentificationNumber;
                        userEdit.Status = MyEnums.StatusOptions.Edited;
                        
                        if (userEdit.Cheker == User.Identity.GetUserName())
                        {
                            userEdit.Cheker = "";
                        }
                        UserStore<ApplicationUser> store = new UserStore<ApplicationUser>();
                        await store.SetPasswordHashAsync(userEdit, hashedNewPassword);
                        await _userManager.UpdateAsync(userEdit);
                      
                        _getVals.LogAudit(User.Identity.GetUserName(), "Edited", Request.UserHostName,
                            "Edited User: " + "Old FirstName: " + TempData["firstname"] + " " + "New FirstName: " + model.Firstname + Environment.NewLine
                        + "Old LastName: " + TempData["lastname"] + " " + "New LastName: " + " " + model.Lastname + Environment.NewLine
                        + "Old GroupId: " + TempData["group"] + " " + "New GroupId: " + group.Id + Environment.NewLine
                        + "Old Country: " + TempData["country"] + " " + "New Country: " + model.Country + Environment.NewLine
                        + "Old Company: " + TempData["company"] + " " + "New Company: " + model.Company + Environment.NewLine
                        + "Old AlternateNumber: " + TempData["alternatenumber"] + " " + "New AlternateNumber: " + model.AlternateNumber + Environment.NewLine
                        + "Old PhoneNumber: " + TempData["phnenumber"] + " " + "New PhoneNumber: " + model.PhoneNumber + Environment.NewLine
                        + "Old Email: " + TempData["email"] + " " + "New Email: " + model.Email + Environment.NewLine
                        + "Old IdentificationNumber: " + TempData["id"] + " " + "New IdentificationNumber: " + model.IdentificationNumber + Environment.NewLine + " With Group: " + group.Name, "ISA", "UserManagement");
                    }
                    else
                    {

                        var userData = _userManager.FindById(model.Id);
                        TempData["firstname"] = userData.FirstName;
                        TempData["lastname"] = userData.LastName;
                        TempData["group"] = userData.GroupId;
                        TempData["country"] = userData.Country;
                        TempData["company"] = userData.Company;
                        TempData["alternatenumber"] = userData.AlternateNumber;
                        TempData["phnenumber"] = userData.PhoneNumber;
                        TempData["email"] = userData.Email;
                        TempData["id"] = userData.IdentificationNumber;



                        var userEdit = _userManager.FindById(model.Id);
                        userEdit.UserName = model.UserName.ToLower();
                        userEdit.PasswordHash = model.UserName.ToLower() + "1234";
                        String hashedNewPassword = _userManager.PasswordHasher.HashPassword(userEdit.PasswordHash);
                        userEdit.EditDateTime = DateTime.Now;
                        userEdit.Maker = User.Identity.GetUserName();
                        userEdit.FirstName = model.Firstname;
                        userEdit.LastName = model.Lastname;
                        userEdit.GroupId = userEdit.GroupId;
                        userEdit.Country = model.Country;
                        userEdit.Company = model.Company;
                        userEdit.AlternateNumber = model.AlternateNumber;
                        userEdit.PhoneNumber = model.PhoneNumber;
                        userEdit.Email = model.Email;
                        userEdit.IdentificationNumber = model.IdentificationNumber;
                        userEdit.Status = MyEnums.StatusOptions.Edited;
                        if (userEdit.Cheker == User.Identity.GetUserName())
                        {
                            userEdit.Cheker = "";
                        }
                        UserStore<ApplicationUser> store = new UserStore<ApplicationUser>();
                        await store.SetPasswordHashAsync(userEdit, hashedNewPassword);
                        await _userManager.UpdateAsync(userEdit);
//.........这里部分代码省略.........
开发者ID:ongeri,项目名称:citieuc,代码行数:101,代码来源:AccountController.cs


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