diff --git a/src/Infrastructure/BotSharp.Abstraction/Users/Models/User.cs b/src/Infrastructure/BotSharp.Abstraction/Users/Models/User.cs index cb48701f..29577f7e 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Users/Models/User.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Users/Models/User.cs @@ -21,6 +21,7 @@ public class User public string Role { get; set; } = UserRole.User; public string? VerificationCode { get; set; } public bool Verified { get; set; } + public string? RegionCode { get; set; } public string? AffiliateId { get; set; } public bool IsDisabled { get; set; } public DateTime UpdatedTime { get; set; } = DateTime.UtcNow; diff --git a/src/Infrastructure/BotSharp.Core/Users/Services/UserService.cs b/src/Infrastructure/BotSharp.Core/Users/Services/UserService.cs index 5d08c51f..4ee5970e 100644 --- a/src/Infrastructure/BotSharp.Core/Users/Services/UserService.cs +++ b/src/Infrastructure/BotSharp.Core/Users/Services/UserService.cs @@ -91,7 +91,8 @@ public class UserService : IUserService record.Email = user.Email?.ToLower(); if (!string.IsNullOrWhiteSpace(user.Phone)) { - record.Phone = "+" + Regex.Match(user.Phone, @"\d+").Value; + //record.Phone = "+" + Regex.Match(user.Phone, @"\d+").Value; + record.Phone = Regex.Match(user.Phone, @"\d+").Value; } record.Salt = Guid.NewGuid().ToString("N"); record.Password = Utilities.HashTextMd5($"{user.Password}{record.Salt}"); diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Users/UserCreationModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Users/UserCreationModel.cs index b157ef59..f2d9f048 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Users/UserCreationModel.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Users/UserCreationModel.cs @@ -5,18 +5,18 @@ namespace BotSharp.OpenAPI.ViewModels.Users; public class UserCreationModel { public string? UserName { get; set; } - public string FirstName { get; set; } = string.Empty; + public string FirstName { get; set; } = string.Empty; public string? LastName { get; set; } public string? Email { get; set; } public string? Phone { get; set; } public string Password { get; set; } = string.Empty; public string Type { get; set; } = UserType.Client; public string Role { get; set; } = UserRole.User; - + public string? RegionCode { get; set; } public User ToUser() { - return new User - { + return new User + { UserName = UserName, FirstName = FirstName, LastName = LastName, @@ -24,7 +24,8 @@ public class UserCreationModel Phone = Phone, Password = Password, Role = Role, - Type = Type + Type = Type, + RegionCode = RegionCode }; } } diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/UserDocument.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/UserDocument.cs index ffcd71a2..1e6f6655 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/UserDocument.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/UserDocument.cs @@ -18,6 +18,7 @@ public class UserDocument : MongoBase public string Role { get; set; } = null!; public string? VerificationCode { get; set; } public bool Verified { get; set; } + public string? RegionCode { get; set; } public string? AffiliateId { get; set; } public bool IsDisabled { get; set; } public DateTime CreatedTime { get; set; } @@ -43,6 +44,7 @@ public class UserDocument : MongoBase IsDisabled = IsDisabled, VerificationCode = VerificationCode, Verified = Verified, + RegionCode = RegionCode, }; } } \ No newline at end of file diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.User.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.User.cs index c064856c..b62c0eb2 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.User.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.User.cs @@ -70,6 +70,7 @@ public partial class MongoRepository Type = user.Type, VerificationCode = user.VerificationCode, Verified = user.Verified, + RegionCode = user.RegionCode, AffiliateId = user.AffiliateId, IsDisabled = user.IsDisabled, CreatedTime = DateTime.UtcNow, @@ -87,7 +88,9 @@ public partial class MongoRepository .Set(x => x.Phone, user.Phone) .Set(x => x.Salt, user.Salt) .Set(x => x.Password, user.Password) - .Set(x => x.VerificationCode, user.VerificationCode); + .Set(x => x.VerificationCode, user.VerificationCode) + .Set(x => x.UpdatedTime, DateTime.UtcNow) + .Set(x => x.RegionCode, user.RegionCode); _dc.Users.UpdateOne(filter, update); }