From 9da36bcf68635da20ae588f52119b6e01f973fb3 Mon Sep 17 00:00:00 2001 From: colin Date: Fri, 31 Jul 2026 08:10:57 +0800 Subject: [PATCH] feat: Phone code registration password is optional --- .../LINGYUN/Abp/Account/Dto/PhoneRegisterDto.cs | 1 - .../LINGYUN/Abp/Account/AccountAppService.cs | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Dto/PhoneRegisterDto.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Dto/PhoneRegisterDto.cs index 65fdc22f6..1330f54e3 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Dto/PhoneRegisterDto.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Dto/PhoneRegisterDto.cs @@ -27,7 +27,6 @@ public class PhoneRegisterDto [DisplayName("EmailAddress")] public string EmailAddress { get; set; } - [Required] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))] [DataType(DataType.Password)] [DisplayName("Password")] diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountAppService.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountAppService.cs index 80450c50a..6c014341f 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountAppService.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountAppService.cs @@ -121,7 +121,7 @@ public class AccountAppService : AccountApplicationServiceBase, IAccountAppServi CurrentTenant.Id); tempNewUser.SetPhoneNumberRegisterUser(); - (await UserManager.UpdateSecurityStampAsync(tempNewUser)).CheckErrors(); + await UserStore.SetSecurityStampAsync(tempNewUser, Guid.NewGuid().ToString("n")); var code = await UserManager.GenerateUserTokenAsync( tempNewUser, @@ -182,7 +182,10 @@ public class AccountAppService : AccountApplicationServiceBase, IAccountAppServi }; (await UserManager.SetPhoneNumberAsync(user, input.PhoneNumber)).CheckErrors(); - (await UserManager.CreateAsync(user, input.Password)).CheckErrors(); + if (!input.Password.IsNullOrWhiteSpace()) + { + (await UserManager.CreateAsync(user, input.Password)).CheckErrors(); + } await UserStore.SetPhoneNumberConfirmedAsync(user, true);