Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lida dev #36

Merged
merged 3 commits into from
Oct 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down