|
@@ -24,6 +24,7 @@ using IdentityModel;
|
|
using Mapster;
|
|
using Mapster;
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.Extensions.Options;
|
|
using Microsoft.Extensions.Options;
|
|
|
|
+using SqlSugar;
|
|
using XF.Domain.Authentications;
|
|
using XF.Domain.Authentications;
|
|
using XF.Domain.Cache;
|
|
using XF.Domain.Cache;
|
|
using XF.Domain.Dependency;
|
|
using XF.Domain.Dependency;
|
|
@@ -50,6 +51,7 @@ public class IdentityAppService : IIdentityAppService, IScopeDependency
|
|
private readonly IThirdIdentiyService _thirdIdentiyService;
|
|
private readonly IThirdIdentiyService _thirdIdentiyService;
|
|
private readonly IThirdAccountRepository _thirdAccountRepository;
|
|
private readonly IThirdAccountRepository _thirdAccountRepository;
|
|
private readonly IRepository<GuiderInfo> _guiderInfoRepository;
|
|
private readonly IRepository<GuiderInfo> _guiderInfoRepository;
|
|
|
|
+ private readonly IVolunteerRepository _volunteerRepository;
|
|
|
|
|
|
public IdentityAppService(
|
|
public IdentityAppService(
|
|
IAccountRepository accountRepository,
|
|
IAccountRepository accountRepository,
|
|
@@ -66,7 +68,8 @@ public class IdentityAppService : IIdentityAppService, IScopeDependency
|
|
IThirdAccountRepository thirdAccountRepository,
|
|
IThirdAccountRepository thirdAccountRepository,
|
|
ISessionContext sessionContext,
|
|
ISessionContext sessionContext,
|
|
IRepository<Citizen> citizenRepository,
|
|
IRepository<Citizen> citizenRepository,
|
|
- IRepository<GuiderInfo> guiderInfoRepository)
|
|
|
|
|
|
+ IRepository<GuiderInfo> guiderInfoRepository,
|
|
|
|
+ IVolunteerRepository volunteerRepository)
|
|
{
|
|
{
|
|
_accountRepository = accountRepository;
|
|
_accountRepository = accountRepository;
|
|
_accountDomainService = accountDomainService;
|
|
_accountDomainService = accountDomainService;
|
|
@@ -83,6 +86,7 @@ public class IdentityAppService : IIdentityAppService, IScopeDependency
|
|
_sessionContext = sessionContext;
|
|
_sessionContext = sessionContext;
|
|
_citizenRepository = citizenRepository;
|
|
_citizenRepository = citizenRepository;
|
|
_guiderInfoRepository = guiderInfoRepository;
|
|
_guiderInfoRepository = guiderInfoRepository;
|
|
|
|
+ _volunteerRepository = volunteerRepository;
|
|
}
|
|
}
|
|
|
|
|
|
public async Task<string> OldToNewLoginAsync(HotlineLoginOldToNewDto dto, CancellationToken cancellationToken)
|
|
public async Task<string> OldToNewLoginAsync(HotlineLoginOldToNewDto dto, CancellationToken cancellationToken)
|
|
@@ -340,6 +344,7 @@ public class IdentityAppService : IIdentityAppService, IScopeDependency
|
|
var expiredSeconds = jwtOptions.Expired <= 0 ? 3600 : jwtOptions.Expired;
|
|
var expiredSeconds = jwtOptions.Expired <= 0 ? 3600 : jwtOptions.Expired;
|
|
await _cacheAudience.SetAsync(audience.Id, audience, TimeSpan.FromSeconds(expiredSeconds));
|
|
await _cacheAudience.SetAsync(audience.Id, audience, TimeSpan.FromSeconds(expiredSeconds));
|
|
var token = _jwtSecurity.EncodeJwtToken(claims, audience.Ticket);
|
|
var token = _jwtSecurity.EncodeJwtToken(claims, audience.Ticket);
|
|
- return new TokenOutDto(thirdAccount.CitizenType, token);
|
|
|
|
|
|
+ var isVolunteer = await _volunteerRepository.IsVolunteerAsync(thirdAccount.PhoneNumber);
|
|
|
|
+ return new TokenOutDto(thirdAccount.CitizenType, token, isVolunteer);
|
|
}
|
|
}
|
|
}
|
|
}
|