From 603f094b1e90d65cf999a1f9ecd5ba06636a555f Mon Sep 17 00:00:00 2001 From: enisn Date: Tue, 17 Aug 2021 11:22:54 +0300 Subject: [PATCH] identity - implement concurrency stamp --- .../Volo/Abp/Identity/ProfileDto.cs | 7 +++++-- .../Volo/Abp/Identity/UpdateProfileDto.cs | 3 +++ .../Volo/Abp/Identity/IdentityRoleAppService.cs | 6 ++++-- .../Volo/Abp/Identity/IdentityUserAppService.cs | 4 +++- .../Volo/Abp/Identity/ProfileAppService.cs | 3 +++ 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/ProfileDto.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/ProfileDto.cs index 98469700a9..659954ae8a 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/ProfileDto.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/ProfileDto.cs @@ -1,8 +1,9 @@ -using Volo.Abp.ObjectExtending; +using Volo.Abp.Domain.Entities; +using Volo.Abp.ObjectExtending; namespace Volo.Abp.Identity { - public class ProfileDto : ExtensibleObject + public class ProfileDto : ExtensibleObject, IHasConcurrencyStamp { public string UserName { get; set; } @@ -17,5 +18,7 @@ namespace Volo.Abp.Identity public bool IsExternal { get; set; } public bool HasPassword { get; set; } + + public string ConcurrencyStamp { get; set; } } } diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/UpdateProfileDto.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/UpdateProfileDto.cs index 5e0397bdfa..9ebf54ba5e 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/UpdateProfileDto.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/UpdateProfileDto.cs @@ -1,4 +1,5 @@ using System.ComponentModel.DataAnnotations; +using Volo.Abp.Domain.Entities; using Volo.Abp.ObjectExtending; using Volo.Abp.Validation; @@ -20,5 +21,7 @@ namespace Volo.Abp.Identity [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPhoneNumberLength))] public string PhoneNumber { get; set; } + + public string ConcurrencyStamp { get; set; } } } \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs index 070f55901e..2686eb6cba 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Volo.Abp.Application.Dtos; +using Volo.Abp.Data; using Volo.Abp.ObjectExtending; namespace Volo.Abp.Identity @@ -72,8 +73,9 @@ namespace Volo.Abp.Identity [Authorize(IdentityPermissions.Roles.Update)] public virtual async Task UpdateAsync(Guid id, IdentityRoleUpdateDto input) { - var role = await RoleManager.GetByIdAsync(id); - role.ConcurrencyStamp = input.ConcurrencyStamp; + var role = await RoleManager.GetByIdAsync(id); + + role.SetConcurrencyStamp(input.ConcurrencyStamp); (await RoleManager.SetRoleNameAsync(role, input.Name)).CheckErrors(); diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs index 69fae63d71..08a517d38e 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs @@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Options; using Volo.Abp.Application.Dtos; +using Volo.Abp.Data; using Volo.Abp.ObjectExtending; namespace Volo.Abp.Identity @@ -98,7 +99,8 @@ namespace Volo.Abp.Identity await IdentityOptions.SetAsync(); var user = await UserManager.GetByIdAsync(id); - user.ConcurrencyStamp = input.ConcurrencyStamp; + + user.SetConcurrencyStamp(input.ConcurrencyStamp); (await UserManager.SetUserNameAsync(user, input.UserName)).CheckErrors(); diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/ProfileAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/ProfileAppService.cs index ef3b5fd35d..52a68dc9b4 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/ProfileAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/ProfileAppService.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Options; +using Volo.Abp.Data; using Volo.Abp.Identity.Settings; using Volo.Abp.ObjectExtending; using Volo.Abp.Settings; @@ -62,6 +63,8 @@ namespace Volo.Abp.Identity user.Name = input.Name; user.Surname = input.Surname; + user.SetConcurrencyStamp(input.ConcurrencyStamp); + input.MapExtraPropertiesTo(user); (await UserManager.UpdateAsync(user)).CheckErrors();