Merge pull request #42 from AnonymousDotNet/lida_Dev

Lida dev
This commit is contained in:
Haiping 2024-11-11 23:15:13 +00:00 committed by GitHub
commit 35dc1ea692
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -15,21 +15,14 @@ public partial class MongoRepository
public User? GetUserByPhone(string phone, string regionCode = "CN")
{
string phoneSecond = string.Empty;
// 如果电话号码长度小于 4直接返回 null
if (phone?.Length < 4)
if (string.IsNullOrWhiteSpace(phone))
{
return null;
}
if (phone.Substring(0, 3) != "+86")
{
phoneSecond = $"+86{phone}";
}
else
{
phoneSecond = phone.Replace("+86", "");
}
var user = _dc.Users.AsQueryable().FirstOrDefault(x => (x.Phone == phone || x.Phone == phoneSecond) && x.Type != UserType.Affiliate && x.RegionCode == regionCode);
string phoneSecond = phone.StartsWith("+86") ? phone.Replace("+86", "") : $"+86{phone}";
var user = _dc.Users.AsQueryable().FirstOrDefault(x => (x.Phone == phone || x.Phone == phoneSecond) && x.Type != UserType.Affiliate && (x.RegionCode == regionCode || x.RegionCode == null));
return user != null ? user.ToUser() : null;
}