add chat and users
This commit is contained in:
@@ -34,9 +34,9 @@ public sealed class AuthService : IAuthService
|
||||
SendCodeRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var mobile = NormalizeMobile(request.Mobile);
|
||||
var mobile = Domain.MobileNormalizer.Normalize(request.Mobile);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(mobile) || mobile.Length != 11 || !mobile.StartsWith("09"))
|
||||
if (mobile.Length == 0)
|
||||
{
|
||||
return new SendCodeResponse
|
||||
{
|
||||
@@ -117,7 +117,7 @@ public sealed class AuthService : IAuthService
|
||||
VerifyCodeRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var mobile = NormalizeMobile(request.Mobile);
|
||||
var mobile = Domain.MobileNormalizer.Normalize(request.Mobile);
|
||||
var code = request.Code.Trim();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(mobile) || string.IsNullOrWhiteSpace(code) || code.Length != 4)
|
||||
@@ -186,7 +186,7 @@ public sealed class AuthService : IAuthService
|
||||
|
||||
public async Task<bool> CanResendCodeAsync(string mobile, CancellationToken cancellationToken)
|
||||
{
|
||||
var normalizedMobile = NormalizeMobile(mobile);
|
||||
var normalizedMobile = Domain.MobileNormalizer.Normalize(mobile);
|
||||
var lastCode = await _dbContext.VerificationCodes
|
||||
.Where(v => v.Mobile == normalizedMobile && !v.IsUsed)
|
||||
.OrderByDescending(v => v.CreatedAt)
|
||||
@@ -252,20 +252,4 @@ public sealed class AuthService : IAuthService
|
||||
return $"{payload}.{signature}";
|
||||
}
|
||||
|
||||
private static string NormalizeMobile(string mobile)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(mobile))
|
||||
return string.Empty;
|
||||
|
||||
var normalized = new string(mobile.Where(char.IsDigit).ToArray());
|
||||
|
||||
if (normalized.StartsWith("9") && normalized.Length == 10)
|
||||
normalized = "0" + normalized;
|
||||
else if (normalized.StartsWith("0098") && normalized.Length == 13)
|
||||
normalized = "0" + normalized.Substring(3);
|
||||
else if (normalized.StartsWith("98") && normalized.Length == 12)
|
||||
normalized = "0" + normalized.Substring(2);
|
||||
|
||||
return normalized;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user