From 4d829820bbcaaf36b52bdb069a09860d80c54fe6 Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 15 Feb 2021 17:29:44 +0800 Subject: [PATCH] UpdatePasswordHash first when create an user & remove PasswordOptionsExtensions. --- .../Volo/Abp/Identity/IdentityUserManager.cs | 4 +-- .../Abp/Identity/PasswordOptionsExtensions.cs | 35 ------------------- 2 files changed, 2 insertions(+), 37 deletions(-) delete mode 100644 modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/PasswordOptionsExtensions.cs diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs index 6450adfad9..508728eea1 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs @@ -62,13 +62,13 @@ namespace Volo.Abp.Identity public virtual async Task CreateAsync(IdentityUser user, string password, bool validatePassword) { - var result = await CreateAsync(user); + var result = await UpdatePasswordHash(user, password, validatePassword); if (!result.Succeeded) { return result; } - return await UpdatePasswordHash(user, password, validatePassword); + return await CreateAsync(user); } public virtual async Task GetByIdAsync(Guid id) diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/PasswordOptionsExtensions.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/PasswordOptionsExtensions.cs deleted file mode 100644 index 793cc6349e..0000000000 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/PasswordOptionsExtensions.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using Microsoft.AspNetCore.Identity; - -namespace Volo.Abp.Identity -{ - public static class PasswordOptionsExtensions - { - public static IDisposable ClearRequirements(this PasswordOptions options) - { - var oldRequireDigit = options.RequireDigit; - var oldRequiredLength = options.RequiredLength; - var oldRequireLowercase = options.RequireLowercase; - var oldRequireUppercase = options.RequireUppercase; - var oldRequiredUniqueChars = options.RequiredUniqueChars; - var oldRequireNonAlphanumeric = options.RequireNonAlphanumeric; - - options.RequireDigit = false; - options.RequiredLength = 1; - options.RequireLowercase = false; - options.RequireUppercase = false; - options.RequiredUniqueChars = 1; - options.RequireNonAlphanumeric = false; - - return new DisposeAction(() => - { - options.RequireDigit = oldRequireDigit; - options.RequiredLength = oldRequiredLength; - options.RequireLowercase = oldRequireLowercase; - options.RequireUppercase = oldRequireUppercase; - options.RequiredUniqueChars = oldRequiredUniqueChars; - options.RequireNonAlphanumeric = oldRequireNonAlphanumeric; - }); - } - } -}