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


C# UserManager.HasPasswordAsync方法代码示例

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


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

示例1: ToViewModel

 public static async Task<IndexViewModel> ToViewModel(this ApplicationUser user, UserManager<ApplicationUser> userManager, SignInManager<ApplicationUser> signInManager)
 {
     var result = new IndexViewModel
     {
         HasPassword = await userManager.HasPasswordAsync(user),
         EmailAddress = user.Email,
         IsEmailAddressConfirmed = user.EmailConfirmed,
         IsPhoneNumberConfirmed = user.PhoneNumberConfirmed,
         PhoneNumber = await userManager.GetPhoneNumberAsync(user),
         TwoFactor = await userManager.GetTwoFactorEnabledAsync(user),
         Logins = await userManager.GetLoginsAsync(user),
         BrowserRemembered = await signInManager.IsTwoFactorClientRememberedAsync(user),
         AssociatedSkills = user.AssociatedSkills,
         TimeZoneId = user.TimeZoneId,
         Name = user.Name,
         ProposedNewEmailAddress = user.PendingNewEmail
     };
     return result;
 }
开发者ID:jwendl,项目名称:allReady,代码行数:19,代码来源:ManageViewModels.cs

示例2: ToViewModel

 public static async Task<IndexViewModel> ToViewModel(this ApplicationUser user, UserManager<ApplicationUser> userManager, SignInManager<ApplicationUser> signInManager)
 {
     var profileCompletenessWarnings = user.ValidateProfileCompleteness();
     var result = new IndexViewModel
     {
         HasPassword = await userManager.HasPasswordAsync(user),
         EmailAddress = user.Email,
         IsEmailAddressConfirmed = user.EmailConfirmed,
         IsPhoneNumberConfirmed = user.PhoneNumberConfirmed,
         PhoneNumber = await userManager.GetPhoneNumberAsync(user),
         TwoFactor = await userManager.GetTwoFactorEnabledAsync(user),
         Logins = await userManager.GetLoginsAsync(user),
         BrowserRemembered = await signInManager.IsTwoFactorClientRememberedAsync(user),
         AssociatedSkills = user.AssociatedSkills,
         TimeZoneId = user.TimeZoneId,
         FirstName = user.FirstName,
         LastName = user.LastName,
         ProposedNewEmailAddress = user.PendingNewEmail,
         IsProfileComplete = user.IsProfileComplete(),
         ProfileCompletenessWarnings = profileCompletenessWarnings.Select(p => p.ErrorMessage)
     };
     return result;
 }
开发者ID:nicolastarzia,项目名称:allReady,代码行数:23,代码来源:ApplicationUserExtensions.cs

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


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