Browse Source

Merge pull request #1491 from colinin/fix-issues

fix: Fix some issues
pull/1492/head
yx lin 4 months ago
committed by GitHub
parent
commit
3243fef962
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 7
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/SingleMigrationsEntityFrameworkCoreMySqlModule.cs
  2. 39
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/Volo/Abp/OpenIddict/Tokens/EfCoreMySqlOpenIddictTokenRepository.cs
  3. 2
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/MyProfileAppService.cs

7
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<OpenIddictDbContext>(options =>
{
options.AddRepository<OpenIddictToken, EfCoreMySqlOpenIddictTokenRepository>();
});
}
}
}

39
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<IOpenIddictDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
public async override Task<long> PruneAsync(DateTime date, CancellationToken cancellationToken = default)
{
var dbContext = await GetDbContextAsync();
var tokens = await (from token in dbContext.Set<OpenIddictToken>()
join authorization in dbContext.Set<OpenIddictAuthorization>()
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;
}
}

2
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]);
}
// 是否已有用户使用手机号绑定

Loading…
Cancel
Save