|
|
|
@ -163,9 +163,14 @@ namespace Shentun.WebPeis.Persons |
|
|
|
throw new UserFriendlyException("手机号码必须为11位"); |
|
|
|
} |
|
|
|
|
|
|
|
if (_cache.Get(CacheKeys.SmsKey + input.MobileTelephone) != input.SmsVerifyCode) |
|
|
|
if (string.IsNullOrWhiteSpace(input.SmsVerifyCodeKey)) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("无效的短信校验码"); |
|
|
|
throw new UserFriendlyException("短信校验码键不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
if (_cache.Get(input.SmsVerifyCodeKey) != input.SmsVerifyCode) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("无效的短信校验码或已过期"); |
|
|
|
} |
|
|
|
|
|
|
|
var person = await _repository.FindAsync(o => o.IdNo == input.IdNo); |
|
|
|
@ -247,9 +252,14 @@ namespace Shentun.WebPeis.Persons |
|
|
|
throw new UserFriendlyException("亲属关系不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
if (_cache.Get(CacheKeys.SmsKey + input.MobileTelephone) != input.SmsVerifyCode) |
|
|
|
if (string.IsNullOrWhiteSpace(input.SmsVerifyCodeKey)) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("无效的短信校验码"); |
|
|
|
throw new UserFriendlyException("短信校验码键不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
if (_cache.Get(input.SmsVerifyCodeKey) != input.SmsVerifyCode) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("无效的短信校验码或已过期"); |
|
|
|
} |
|
|
|
|
|
|
|
var person = await _repository.FindAsync(o=>o.IdNo == input.IdNo); |
|
|
|
@ -393,8 +403,9 @@ namespace Shentun.WebPeis.Persons |
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
|
|
[AllowAnonymous] |
|
|
|
[HttpPost("api/app/Person/GetSmsVerifyCode")] |
|
|
|
public async Task GetSmsVerifyCodeAsync(SmsVerifyCodeInputDto input) |
|
|
|
public async Task<SmsVerifyCodeDto> GetSmsVerifyCodeAsync(SmsVerifyCodeInputDto input) |
|
|
|
{ |
|
|
|
if(input == null) |
|
|
|
{ |
|
|
|
@ -456,8 +467,15 @@ namespace Shentun.WebPeis.Persons |
|
|
|
MobileTelephone = input.MobileTelephone, |
|
|
|
CountryCode = "86", |
|
|
|
}; |
|
|
|
var message = await SendVerifySms(createSmsTaskDto); |
|
|
|
|
|
|
|
|
|
|
|
var smsVerifyCodeKey = await SendVerifySms(createSmsTaskDto); |
|
|
|
var SmsVerifyCodeDto = new SmsVerifyCodeDto() |
|
|
|
{ |
|
|
|
SmsVerifyCodeKey = smsVerifyCodeKey |
|
|
|
}; |
|
|
|
|
|
|
|
return SmsVerifyCodeDto; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private async Task<UserTokenDto> GetTokenAsync(string request) |
|
|
|
@ -546,8 +564,9 @@ namespace Shentun.WebPeis.Persons |
|
|
|
//存储短信校验码
|
|
|
|
var options = new DistributedCacheEntryOptions() |
|
|
|
.SetAbsoluteExpiration(TimeSpan.FromMinutes(verifySmsValidTime)); |
|
|
|
_cache.Set(CacheKeys.SmsKey + createSmsTaskDto.MobileTelephone, message, options); |
|
|
|
return message; |
|
|
|
var smsVerifyCodeKey = CacheKeys.SmsKey + createSmsTaskDto.MobileTelephone + Guid.NewGuid().ToString(); |
|
|
|
_cache.Set(smsVerifyCodeKey, message, options); |
|
|
|
return smsVerifyCodeKey; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|