Handle verification code sent by logged in users

This commit is contained in:
AnonymousDotNet 2024-09-18 17:55:20 +08:00
parent 0d473168fd
commit 81dfb1f84a

View file

@ -344,24 +344,32 @@ public class UserService : IUserService
public async Task<bool> SendVerificationCodeResetPassword(User user)
{
if (!string.IsNullOrEmpty(user.Email) && !string.IsNullOrEmpty(user.Phone))
{
return false;
}
var db = _services.GetRequiredService<IBotSharpRepository>();
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;