|
@@ -4,12 +4,14 @@ using Hotline.Identity.Accounts;
|
|
|
using Hotline.Push.Notifies;
|
|
|
using Hotline.Share.Dtos.Push;
|
|
|
using Hotline.Share.Enums.Push;
|
|
|
+using Hotline.Users;
|
|
|
using MapsterMapper;
|
|
|
using MediatR;
|
|
|
using XF.Domain.Cache;
|
|
|
using XF.Domain.Constants;
|
|
|
using XF.Domain.Dependency;
|
|
|
using XF.Domain.Exceptions;
|
|
|
+using XF.Domain.Repository;
|
|
|
|
|
|
namespace Hotline.Push
|
|
|
{
|
|
@@ -23,6 +25,7 @@ namespace Hotline.Push
|
|
|
private readonly IAccountRepository _accountRepository;
|
|
|
private readonly ITypedCache<LoginMessageCodeDto> _loginMessageCodeTypedCache;
|
|
|
private readonly ISystemSettingCacheManager _systemSettingCacheManager;
|
|
|
+ private readonly IRepository<User> _userRepository;
|
|
|
|
|
|
/// <summary>
|
|
|
///
|
|
@@ -36,7 +39,8 @@ namespace Hotline.Push
|
|
|
IMediator mediator,
|
|
|
ICapPublisher capPublisher, IAccountRepository accountRepository,
|
|
|
ITypedCache<LoginMessageCodeDto> loginMessageCodeTypedCache,
|
|
|
- ISystemSettingCacheManager systemSettingCacheManager)
|
|
|
+ ISystemSettingCacheManager systemSettingCacheManager,
|
|
|
+ IRepository<User> userRepository)
|
|
|
{
|
|
|
_mapper = mapper;
|
|
|
_mediator = mediator;
|
|
@@ -44,6 +48,7 @@ namespace Hotline.Push
|
|
|
_accountRepository = accountRepository;
|
|
|
_loginMessageCodeTypedCache = loginMessageCodeTypedCache;
|
|
|
_systemSettingCacheManager = systemSettingCacheManager;
|
|
|
+ _userRepository = userRepository;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
@@ -59,7 +64,7 @@ namespace Hotline.Push
|
|
|
return false;
|
|
|
|
|
|
var settingWhite = _systemSettingCacheManager.GetSetting(SettingConstants.LoginCodeWhiteList);
|
|
|
-
|
|
|
+
|
|
|
if (settingWhite == null || !settingWhite.SettingValue.Exists(p => p == UserName))
|
|
|
return true;
|
|
|
|
|
@@ -85,10 +90,11 @@ namespace Hotline.Push
|
|
|
if (account == null)
|
|
|
return "用户名错误!";
|
|
|
|
|
|
- if (string.IsNullOrEmpty(account.PhoneNo))
|
|
|
+ var userInfo = await _userRepository.GetAsync(p => p.Id == account.Id);
|
|
|
+ if (userInfo == null || string.IsNullOrEmpty(userInfo.PhoneNo))
|
|
|
return "用户未配置手机号码!";
|
|
|
|
|
|
- string strKeyToken = KeyToken + account.PhoneNo;
|
|
|
+ string strKeyToken = KeyToken + userInfo.PhoneNo;
|
|
|
|
|
|
var token = await _loginMessageCodeTypedCache.GetAsync(strKeyToken, cancellation);
|
|
|
if (token != null)
|
|
@@ -117,7 +123,7 @@ namespace Hotline.Push
|
|
|
Name = account.Name,
|
|
|
TemplateCode = "1006",
|
|
|
Params = new List<string>() { token.Code },
|
|
|
- TelNumber = account.PhoneNo,
|
|
|
+ TelNumber = userInfo.PhoneNo,
|
|
|
|
|
|
};
|
|
|
await _mediator.Publish(new PushMessageNotify(messageDto), cancellation);
|