From 511eae2d2a3d4b02a8e50adb041a3c60ba8ca6ea Mon Sep 17 00:00:00 2001 From: colin Date: Thu, 28 May 2026 16:59:57 +0800 Subject: [PATCH 1/2] fix: Fix the issue of sending duplicate SMS verification codes - Fix the prompt for repeated sending of SMS verification code messages --- .../LINGYUN/Abp/Account/MyProfileAppService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/MyProfileAppService.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/MyProfileAppService.cs index b0613662d..c0008d913 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/MyProfileAppService.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/MyProfileAppService.cs @@ -140,7 +140,7 @@ public class MyProfileAppService : AccountApplicationServiceBase, IMyProfileAppS var interval = await SettingProvider.GetAsync(Identity.Settings.IdentitySettingNames.User.SmsRepetInterval, 1); if (securityTokenCacheItem != null) { - throw new UserFriendlyException(L["SendRepeatPhoneVerifyCode", interval]); + throw new UserFriendlyException(L["SendRepeatSmsVerifyCode", interval]); } // 是否已有用户使用手机号绑定 From c94b09841527d9e5b60d18f2f10fdcee67363b78 Mon Sep 17 00:00:00 2001 From: colin Date: Thu, 28 May 2026 17:01:07 +0800 Subject: [PATCH 2/2] fix: Fix the MySQL token cleanup issue - After querying the expired token collection, then delete it --- ...igrationsEntityFrameworkCoreMySqlModule.cs | 7 ++++ .../EfCoreMySqlOpenIddictTokenRepository.cs | 39 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/Volo/Abp/OpenIddict/Tokens/EfCoreMySqlOpenIddictTokenRepository.cs diff --git a/aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/SingleMigrationsEntityFrameworkCoreMySqlModule.cs b/aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/SingleMigrationsEntityFrameworkCoreMySqlModule.cs index d9187af38..d09ca5c43 100644 --- a/aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/SingleMigrationsEntityFrameworkCoreMySqlModule.cs +++ b/aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/SingleMigrationsEntityFrameworkCoreMySqlModule.cs @@ -8,6 +8,8 @@ using System; using Volo.Abp.EntityFrameworkCore; using Volo.Abp.Guids; using Volo.Abp.Modularity; +using Volo.Abp.OpenIddict.EntityFrameworkCore; +using Volo.Abp.OpenIddict.Tokens; namespace LY.MicroService.Applications.Single.EntityFrameworkCore.MySql; @@ -64,6 +66,11 @@ public class SingleMigrationsEntityFrameworkCoreMySqlModule : AbpModule options.DefaultSequentialGuidType = SequentialGuidType.SequentialAsString; } }); + + context.Services.AddAbpDbContext(options => + { + options.AddRepository(); + }); } } } diff --git a/aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/Volo/Abp/OpenIddict/Tokens/EfCoreMySqlOpenIddictTokenRepository.cs b/aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/Volo/Abp/OpenIddict/Tokens/EfCoreMySqlOpenIddictTokenRepository.cs new file mode 100644 index 000000000..c5385f120 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/Volo/Abp/OpenIddict/Tokens/EfCoreMySqlOpenIddictTokenRepository.cs @@ -0,0 +1,39 @@ +using Microsoft.EntityFrameworkCore; +using OpenIddict.Abstractions; +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.OpenIddict.Authorizations; +using Volo.Abp.OpenIddict.EntityFrameworkCore; + +namespace Volo.Abp.OpenIddict.Tokens; + +public class EfCoreMySqlOpenIddictTokenRepository : EfCoreOpenIddictTokenRepository +{ + public EfCoreMySqlOpenIddictTokenRepository( + IDbContextProvider dbContextProvider) + : base(dbContextProvider) + { + } + + public async override Task PruneAsync(DateTime date, CancellationToken cancellationToken = default) + { + var dbContext = await GetDbContextAsync(); + var tokens = await (from token in dbContext.Set() + join authorization in dbContext.Set() + on token.AuthorizationId equals authorization.Id into tokenAuthorizations + from tokenAuthorization in tokenAuthorizations.DefaultIfEmpty() + where token.CreationDate < date + where (token.Status != OpenIddictConstants.Statuses.Inactive && token.Status != OpenIddictConstants.Statuses.Valid) || + (tokenAuthorization != null && tokenAuthorization.Status != OpenIddictConstants.Statuses.Valid) || + token.ExpirationDate < DateTime.UtcNow + select token) + .ToListAsync(GetCancellationToken(cancellationToken)); + + await DeleteManyAsync(tokens, cancellationToken: GetCancellationToken(cancellationToken)); + + return tokens.Count; + } +}