From 81dfb1f84a337cc3ba028bd4c1419803cb36b760 Mon Sep 17 00:00:00 2001 From: AnonymousDotNet <18776095145@163.com> Date: Wed, 18 Sep 2024 17:55:20 +0800 Subject: [PATCH] Handle verification code sent by logged in users --- .../Users/Services/UserService.cs | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/Infrastructure/BotSharp.Core/Users/Services/UserService.cs b/src/Infrastructure/BotSharp.Core/Users/Services/UserService.cs index b0830d0c..65efbfd1 100644 --- a/src/Infrastructure/BotSharp.Core/Users/Services/UserService.cs +++ b/src/Infrastructure/BotSharp.Core/Users/Services/UserService.cs @@ -344,24 +344,32 @@ public class UserService : IUserService public async Task SendVerificationCodeResetPassword(User user) { - if (!string.IsNullOrEmpty(user.Email) && !string.IsNullOrEmpty(user.Phone)) - { - return false; - } - var db = _services.GetRequiredService(); User? record = null; - if (!string.IsNullOrEmpty(user.Email)) + if (!string.IsNullOrWhiteSpace(_user.Id)) { - record = db.GetUserByEmail(user.Email); + record = db.GetUserById(_user.Id); + } + else + { + if (!string.IsNullOrEmpty(user.Email) && !string.IsNullOrEmpty(user.Phone)) + { + return false; + } + + if (!string.IsNullOrEmpty(user.Email)) + { + record = db.GetUserByEmail(user.Email); + } + + if (!string.IsNullOrEmpty(user.Phone)) + { + record = db.GetUserByPhone(user.Phone); + } } - if (!string.IsNullOrEmpty(user.Phone)) - { - record = db.GetUserByPhone(user.Phone); - } if (record == null) { return false;