Merge pull request #36 from AnonymousDotNet/lida_Dev

Lida dev
This commit is contained in:
Haiping 2024-10-30 08:22:41 -05:00 committed by GitHub
commit 532aa86968
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -14,10 +14,19 @@ public partial class MongoRepository
public User? GetUserByPhone(string phone)
{
string phoneSecond = string.Empty;
if (phone.Length >= 4 && phone.Substring(0, 3) != "+86")
// 如果电话号码长度小于 4直接返回 null
if (phone?.Length < 4)
{
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);
return user != null ? user.ToUser() : null;
}