From cb7285f33693a7919907a5832469d24a49d6051e Mon Sep 17 00:00:00 2001 From: AnonymousDotNet <18776095145@163.com> Date: Fri, 18 Oct 2024 15:43:34 +0800 Subject: [PATCH 01/12] add RegionCode --- .../BotSharp.Plugin.MongoStorage/Collections/UserDocument.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/UserDocument.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/UserDocument.cs index ffcd71a2..d76ec389 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; } From 3e1fd96ef861c4aa3a6d3eb501ac02ce04430d07 Mon Sep 17 00:00:00 2001 From: AnonymousDotNet <18776095145@163.com> Date: Mon, 21 Oct 2024 19:59:05 +0800 Subject: [PATCH 02/12] fix: Update CreateUser API --- .../BotSharp.Abstraction/Users/Models/User.cs | 1 + .../BotSharp.Core/Users/Services/UserService.cs | 3 ++- .../ViewModels/Users/UserCreationModel.cs | 11 ++++++----- .../Collections/UserDocument.cs | 2 ++ .../Repository/MongoRepository.User.cs | 5 ++++- 5 files changed, 15 insertions(+), 7 deletions(-) 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); } From 75bf0425070fff623309836943938f0ffd427b36 Mon Sep 17 00:00:00 2001 From: AnonymousDotNet <18776095145@163.com> Date: Tue, 22 Oct 2024 17:43:15 +0800 Subject: [PATCH 03/12] fix: add RegionCode --- .../ViewModels/Users/UserResetPasswordModel.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Users/UserResetPasswordModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Users/UserResetPasswordModel.cs index 8a58820a..df0601c5 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Users/UserResetPasswordModel.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Users/UserResetPasswordModel.cs @@ -1,5 +1,3 @@ -using System.Data; - namespace BotSharp.OpenAPI.ViewModels.Users; public class UserResetPasswordModel @@ -8,6 +6,7 @@ public class UserResetPasswordModel public string? Phone { get; set; } public string Password { get; set; } = string.Empty; public string VerificationCode { get; set; } + public string? RegionCode { get; set; } public User ToUser() { From 4b2a94a5391595b4bb35b7165910d2b7ec658714 Mon Sep 17 00:00:00 2001 From: AnonymousDotNet <18776095145@163.com> Date: Tue, 22 Oct 2024 18:43:34 +0800 Subject: [PATCH 04/12] fix: add regionCode for ModifyUserPhone API --- .../Repositories/IBotSharpRepository.cs | 2 +- .../BotSharp.Abstraction/Users/IUserService.cs | 2 +- .../BotSharp.Core/Users/Services/UserService.cs | 11 ++++++++--- .../BotSharp.OpenAPI/Controllers/UserController.cs | 4 ++-- .../Repository/MongoRepository.User.cs | 5 +++-- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs b/src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs index 4ef68d88..003eddf4 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs @@ -32,7 +32,7 @@ public interface IBotSharpRepository void UpdateUserVerificationCode(string userId, string verficationCode) => throw new NotImplementedException(); void UpdateUserPassword(string userId, string password) => throw new NotImplementedException(); void UpdateUserEmail(string userId, string email) => throw new NotImplementedException(); - void UpdateUserPhone(string userId, string Iphone) => throw new NotImplementedException(); + void UpdateUserPhone(string userId, string Iphone, string regionCode) => throw new NotImplementedException(); void UpdateUserIsDisable(string userId, bool isDisable) => throw new NotImplementedException(); void UpdateUsersIsDisable(List userIds, bool isDisable) => throw new NotImplementedException(); #endregion diff --git a/src/Infrastructure/BotSharp.Abstraction/Users/IUserService.cs b/src/Infrastructure/BotSharp.Abstraction/Users/IUserService.cs index d5547051..8123b272 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Users/IUserService.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Users/IUserService.cs @@ -19,7 +19,7 @@ public interface IUserService Task SendVerificationCodeResetPasswordLogin(); Task ResetUserPassword(User user); Task ModifyUserEmail(string email); - Task ModifyUserPhone(string phone); + Task ModifyUserPhone(string phone, string regionCode); Task UpdatePassword(string newPassword, string verificationCode); Task GetUserTokenExpires(); Task UpdateUsersIsDisable(List userIds, bool isDisable); diff --git a/src/Infrastructure/BotSharp.Core/Users/Services/UserService.cs b/src/Infrastructure/BotSharp.Core/Users/Services/UserService.cs index 43e2dfb7..a56c57a8 100644 --- a/src/Infrastructure/BotSharp.Core/Users/Services/UserService.cs +++ b/src/Infrastructure/BotSharp.Core/Users/Services/UserService.cs @@ -189,7 +189,7 @@ public class UserService : IUserService } var (token, jwt) = BuildToken(record); - + return await Task.FromResult(token); } @@ -618,8 +618,12 @@ public class UserService : IUserService return true; } - public async Task ModifyUserPhone(string phone) + public async Task ModifyUserPhone(string phone, string regionCode) { + if (string.IsNullOrWhiteSpace(regionCode)) + { + throw new Exception("regionCode is required"); + } var curUser = await GetMyProfile(); var db = _services.GetRequiredService(); var record = db.GetUserById(curUser.Id); @@ -631,6 +635,7 @@ public class UserService : IUserService } record.Phone = phone; + record.RegionCode = regionCode; var hooks = _services.GetServices(); foreach (var hook in hooks) @@ -638,7 +643,7 @@ public class UserService : IUserService await hook.UserUpdating(record); } - db.UpdateUserPhone(record.Id, record.Phone); + db.UpdateUserPhone(record.Id, record.Phone, regionCode); return true; } diff --git a/src/Infrastructure/BotSharp.OpenAPI/Controllers/UserController.cs b/src/Infrastructure/BotSharp.OpenAPI/Controllers/UserController.cs index 67c0f4e3..253c19be 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/Controllers/UserController.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/Controllers/UserController.cs @@ -153,9 +153,9 @@ public class UserController : ControllerBase } [HttpPost("/user/phone/modify")] - public async Task ModifyUserPhone([FromQuery] string phone) + public async Task ModifyUserPhone([FromQuery] string phone, [FromQuery] string regionCode) { - return await _userService.ModifyUserPhone(phone); + return await _userService.ModifyUserPhone(phone, regionCode); } [HttpPost("/user/update/isdisable")] diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.User.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.User.cs index cf33312c..7b1f66db 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.User.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.User.cs @@ -128,11 +128,12 @@ public partial class MongoRepository _dc.Users.UpdateOne(filter, update); } - public void UpdateUserPhone(string userId, string phone) + public void UpdateUserPhone(string userId, string phone, string regionCode) { var filter = Builders.Filter.Eq(x => x.Id, userId); var update = Builders.Update.Set(x => x.Phone, phone) - .Set(x => x.UpdatedTime, DateTime.UtcNow); + .Set(x => x.UpdatedTime, DateTime.UtcNow) + .Set(x => x.RegionCode, regionCode); _dc.Users.UpdateOne(filter, update); } From 0f930b4c46c3260d914a0e202d74835877f0eda6 Mon Sep 17 00:00:00 2001 From: AnonymousDotNet <18776095145@163.com> Date: Tue, 22 Oct 2024 18:56:00 +0800 Subject: [PATCH 05/12] fix: update ModifyUserPhone API --- .../BotSharp.Core/Users/Services/UserService.cs | 2 ++ .../Repository/MongoRepository.User.cs | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Infrastructure/BotSharp.Core/Users/Services/UserService.cs b/src/Infrastructure/BotSharp.Core/Users/Services/UserService.cs index a56c57a8..c48001bf 100644 --- a/src/Infrastructure/BotSharp.Core/Users/Services/UserService.cs +++ b/src/Infrastructure/BotSharp.Core/Users/Services/UserService.cs @@ -636,6 +636,8 @@ public class UserService : IUserService record.Phone = phone; record.RegionCode = regionCode; + record.UserName = phone; + record.FirstName = phone; var hooks = _services.GetServices(); foreach (var hook in hooks) diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.User.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.User.cs index 7b1f66db..1d0e2596 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.User.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.User.cs @@ -133,7 +133,9 @@ public partial class MongoRepository var filter = Builders.Filter.Eq(x => x.Id, userId); var update = Builders.Update.Set(x => x.Phone, phone) .Set(x => x.UpdatedTime, DateTime.UtcNow) - .Set(x => x.RegionCode, regionCode); + .Set(x => x.RegionCode, regionCode) + .Set(x => x.UserName, phone) + .Set(x => x.FirstName, phone); _dc.Users.UpdateOne(filter, update); } From 0fbe0e6f0cdf45662eb34a4bf4ef071baf21996c Mon Sep 17 00:00:00 2001 From: AnonymousDotNet <18776095145@163.com> Date: Wed, 23 Oct 2024 14:57:57 +0800 Subject: [PATCH 06/12] feat: add RegionCode by UserIdentity. --- .../BotSharp.Abstraction/Users/IUserIdentity.cs | 1 + .../BotSharp.Core/Users/Services/UserIdentity.cs | 5 ++++- .../BotSharp.Core/Users/Services/UserService.cs | 6 ++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Infrastructure/BotSharp.Abstraction/Users/IUserIdentity.cs b/src/Infrastructure/BotSharp.Abstraction/Users/IUserIdentity.cs index 47e70e42..f42b7f25 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Users/IUserIdentity.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Users/IUserIdentity.cs @@ -17,4 +17,5 @@ public interface IUserIdentity string? EmployeeId { get; } string Type { get; } string Role { get; } + string? RegionCode { get; } } diff --git a/src/Infrastructure/BotSharp.Core/Users/Services/UserIdentity.cs b/src/Infrastructure/BotSharp.Core/Users/Services/UserIdentity.cs index 6ddeae03..965be261 100644 --- a/src/Infrastructure/BotSharp.Core/Users/Services/UserIdentity.cs +++ b/src/Infrastructure/BotSharp.Core/Users/Services/UserIdentity.cs @@ -63,7 +63,7 @@ public class UserIdentity : IUserIdentity get { _contextAccessor.HttpContext.Request.Headers.TryGetValue("User-Language", out var languages); - return languages.FirstOrDefault() ?? "en-US"; + return languages.FirstOrDefault() ?? "en-US"; } } @@ -81,4 +81,7 @@ public class UserIdentity : IUserIdentity [JsonPropertyName("role")] public string? Role => _claims?.FirstOrDefault(x => x.Type == ClaimTypes.Role)?.Value; + + [JsonPropertyName("regionCode")] + public string? RegionCode => _claims?.FirstOrDefault(x => x.Type == "regionCode")?.Value; } diff --git a/src/Infrastructure/BotSharp.Core/Users/Services/UserService.cs b/src/Infrastructure/BotSharp.Core/Users/Services/UserService.cs index c48001bf..dbd8b696 100644 --- a/src/Infrastructure/BotSharp.Core/Users/Services/UserService.cs +++ b/src/Infrastructure/BotSharp.Core/Users/Services/UserService.cs @@ -267,7 +267,8 @@ public class UserService : IUserService ExternalId = user.ExternalId, Password = user.Password, Type = user.Type, - Role = user.Role + Role = user.Role, + RegionCode = user.RegionCode }; await CreateUser(record); } @@ -317,7 +318,8 @@ public class UserService : IUserService new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()), new Claim("phone", user.Phone ?? string.Empty), new Claim("affiliateId", user.AffiliateId ?? string.Empty), - new Claim("employeeId", user.EmployeeId ?? string.Empty) + new Claim("employeeId", user.EmployeeId ?? string.Empty), + new Claim("regionCode", user.RegionCode ?? "CN") }; var validators = _services.GetServices(); From 317f6b147ec186394a3692e4295d590ebf4e1e32 Mon Sep 17 00:00:00 2001 From: AnonymousDotNet <18776095145@163.com> Date: Wed, 23 Oct 2024 15:04:36 +0800 Subject: [PATCH 07/12] fix: Set default values --- .../BotSharp.OpenAPI/ViewModels/Users/UserCreationModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Users/UserCreationModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Users/UserCreationModel.cs index f2d9f048..c55da5fa 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Users/UserCreationModel.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Users/UserCreationModel.cs @@ -12,7 +12,7 @@ public class UserCreationModel 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 string RegionCode { get; set; } = "CN"; public User ToUser() { return new User From 83cf6ae91246f4640bfb947e5a98ff0390154118 Mon Sep 17 00:00:00 2001 From: AnonymousDotNet <18776095145@163.com> Date: Wed, 23 Oct 2024 15:35:05 +0800 Subject: [PATCH 08/12] fix: Set default values --- .../BotSharp.OpenAPI/Controllers/UserController.cs | 2 +- .../BotSharp.OpenAPI/ViewModels/Users/UserResetPasswordModel.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Infrastructure/BotSharp.OpenAPI/Controllers/UserController.cs b/src/Infrastructure/BotSharp.OpenAPI/Controllers/UserController.cs index 253c19be..cb254f50 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/Controllers/UserController.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/Controllers/UserController.cs @@ -153,7 +153,7 @@ public class UserController : ControllerBase } [HttpPost("/user/phone/modify")] - public async Task ModifyUserPhone([FromQuery] string phone, [FromQuery] string regionCode) + public async Task ModifyUserPhone([FromQuery] string phone, [FromQuery] string regionCode = "CN") { return await _userService.ModifyUserPhone(phone, regionCode); } diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Users/UserResetPasswordModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Users/UserResetPasswordModel.cs index df0601c5..0632a8f8 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Users/UserResetPasswordModel.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Users/UserResetPasswordModel.cs @@ -6,7 +6,7 @@ public class UserResetPasswordModel public string? Phone { get; set; } public string Password { get; set; } = string.Empty; public string VerificationCode { get; set; } - public string? RegionCode { get; set; } + public string RegionCode { get; set; } = "CN"; public User ToUser() { From 33945d41eee38d81adedb79a91a80a383c5c0304 Mon Sep 17 00:00:00 2001 From: AnonymousDotNet <18776095145@163.com> Date: Wed, 23 Oct 2024 16:14:25 +0800 Subject: [PATCH 09/12] fix: Set default values --- src/Infrastructure/BotSharp.Abstraction/Users/Models/User.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Infrastructure/BotSharp.Abstraction/Users/Models/User.cs b/src/Infrastructure/BotSharp.Abstraction/Users/Models/User.cs index 7ed9c02d..0baa7457 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Users/Models/User.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Users/Models/User.cs @@ -21,7 +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 RegionCode { get; set; } = "CN"; public string? AffiliateId { get; set; } public string? EmployeeId { get; set; } public bool IsDisabled { get; set; } From d527893b377d3e27d82cf5edb6a3dc8b2f2b22c0 Mon Sep 17 00:00:00 2001 From: AnonymousDotNet <18776095145@163.com> Date: Mon, 28 Oct 2024 10:22:39 +0800 Subject: [PATCH 10/12] fix: add regionCode --- .../ViewModels/Users/UserResetPasswordModel.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Users/UserResetPasswordModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Users/UserResetPasswordModel.cs index 0632a8f8..7837c916 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Users/UserResetPasswordModel.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Users/UserResetPasswordModel.cs @@ -15,7 +15,8 @@ public class UserResetPasswordModel Email = Email, Phone = Phone, Password = Password, - VerificationCode = VerificationCode + VerificationCode = VerificationCode, + RegionCode = RegionCode }; } } From ee3a9507cac34d39fca63cc5d9f36eb6c21b2d8f Mon Sep 17 00:00:00 2001 From: AnonymousDotNet <18776095145@163.com> Date: Mon, 28 Oct 2024 18:12:53 +0800 Subject: [PATCH 11/12] fix: Compatible +86 --- .../Repository/MongoRepository.User.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.User.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.User.cs index 1d0e2596..33cd16e8 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.User.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.User.cs @@ -13,7 +13,12 @@ public partial class MongoRepository public User? GetUserByPhone(string phone) { - var user = _dc.Users.AsQueryable().FirstOrDefault(x => x.Phone == phone && x.Type != UserType.Affiliate); + string phoneSecond = string.Empty; + if (phone.Substring(0, 3) != "+86") + { + phoneSecond = $"+86{phone}"; + } + var user = _dc.Users.AsQueryable().FirstOrDefault(x => (x.Phone == phone || x.Phone == phoneSecond) && x.Type != UserType.Affiliate); return user != null ? user.ToUser() : null; } From d72c4ee610820d02147eda0dd9188693f51b8c1b Mon Sep 17 00:00:00 2001 From: AnonymousDotNet <18776095145@163.com> Date: Mon, 28 Oct 2024 19:44:01 +0800 Subject: [PATCH 12/12] fix: update phone number display --- .../BotSharp.OpenAPI/ViewModels/Users/UserViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Users/UserViewModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Users/UserViewModel.cs index 393bbb86..df60c26c 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Users/UserViewModel.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Users/UserViewModel.cs @@ -47,7 +47,7 @@ public class UserViewModel FirstName = user.FirstName, LastName = user.LastName, Email = user.Email, - Phone = user.Phone, + Phone = user.Phone.Substring(0, 3) == "+86" ? user.Phone.Substring(3) : user.Phone, Type = user.Type, Role = user.Role, Source = user.Source,