diff --git a/src/Infrastructure/BotSharp.Core/Users/Services/UserService.cs b/src/Infrastructure/BotSharp.Core/Users/Services/UserService.cs index 21567df8..98932856 100644 --- a/src/Infrastructure/BotSharp.Core/Users/Services/UserService.cs +++ b/src/Infrastructure/BotSharp.Core/Users/Services/UserService.cs @@ -33,7 +33,7 @@ public class UserService : IUserService public async Task CreateUser(User user) { string hasRegisterId = null; - if (string.IsNullOrEmpty(user.UserName)) + if (string.IsNullOrWhiteSpace(user.UserName)) { // generate unique name var name = Nanoid.Generate("0123456789botsharp", 10); @@ -48,29 +48,24 @@ public class UserService : IUserService User? record = null; - if (user.Phone != null) + if (!string.IsNullOrWhiteSpace(user.Phone)) { record = db.GetUserByPhone(user.Phone); } - if (record == null && user.Email != null) + if (record == null && !string.IsNullOrWhiteSpace(user.Email)) { record = db.GetUserByEmail(user.Email); } - if (record == null && user.UserName != null) - { - record = db.GetUserByUserName(user.UserName); - } - if (record != null) { hasRegisterId = record.Id; } - if (string.IsNullOrEmpty(user.Id)) + if (string.IsNullOrWhiteSpace(user.Id)) { - if (hasRegisterId != null) + if (!string.IsNullOrWhiteSpace(hasRegisterId)) { user.Id = hasRegisterId; }