hdong: clean up code.
This commit is contained in:
parent
3f64f36753
commit
43cf8743b5
|
|
@ -49,7 +49,7 @@ public interface IAuthenticationHook
|
|||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
Task VerificationCodeResetPassword(User user);
|
||||
Task SendVerificationCode(User user);
|
||||
|
||||
/// <summary>
|
||||
/// Delete users
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ public interface IUserService
|
|||
Task<bool> VerifyUserNameExisting(string userName);
|
||||
Task<bool> VerifyEmailExisting(string email);
|
||||
Task<bool> VerifyPhoneExisting(string phone, string regionCode);
|
||||
Task<bool> SendVerificationCodeResetPasswordNoLogin(User user);
|
||||
Task<bool> SendVerificationCodeResetPasswordLogin();
|
||||
Task<bool> SendVerificationCodeNoLogin(User user);
|
||||
Task<bool> SendVerificationCodeLogin();
|
||||
Task<bool> SetUserPassword(User user);
|
||||
Task<bool> ResetUserPassword(User user);
|
||||
Task<bool> ModifyUserEmail(string email);
|
||||
|
|
|
|||
|
|
@ -53,14 +53,7 @@ public class UserService : IUserService
|
|||
record = db.GetUserByUserName(user.UserName);
|
||||
}
|
||||
|
||||
if (record != null && record.Verified)
|
||||
{
|
||||
// account is already activated
|
||||
_logger.LogWarning($"User account already exists: {record.Id} {record.UserName}");
|
||||
return record;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(user.Phone))
|
||||
if (record == null && !string.IsNullOrWhiteSpace(user.Phone))
|
||||
{
|
||||
record = db.GetUserByPhone(user.Phone, regionCode: (string.IsNullOrWhiteSpace(user.RegionCode) ? "CN" : user.RegionCode));
|
||||
}
|
||||
|
|
@ -70,6 +63,13 @@ public class UserService : IUserService
|
|||
record = db.GetUserByEmail(user.Email);
|
||||
}
|
||||
|
||||
if (record != null && record.Verified)
|
||||
{
|
||||
// account is already activated
|
||||
_logger.LogWarning($"User account already exists: {record.Id} {record.UserName}");
|
||||
return record;
|
||||
}
|
||||
|
||||
if (record != null)
|
||||
{
|
||||
hasRegisterId = record.Id;
|
||||
|
|
@ -94,6 +94,7 @@ public class UserService : IUserService
|
|||
//record.Phone = "+" + Regex.Match(user.Phone, @"\d+").Value;
|
||||
record.Phone = Regex.Match(user.Phone, @"\d+").Value;
|
||||
}
|
||||
|
||||
record.Salt = Guid.NewGuid().ToString("N");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(user.Password))
|
||||
|
|
@ -586,7 +587,7 @@ public class UserService : IUserService
|
|||
return false;
|
||||
}
|
||||
|
||||
public async Task<bool> SendVerificationCodeResetPasswordNoLogin(User user)
|
||||
public async Task<bool> SendVerificationCodeNoLogin(User user)
|
||||
{
|
||||
var db = _services.GetRequiredService<IBotSharpRepository>();
|
||||
|
||||
|
|
@ -621,13 +622,13 @@ public class UserService : IUserService
|
|||
var hooks = _services.GetServices<IAuthenticationHook>();
|
||||
foreach (var hook in hooks)
|
||||
{
|
||||
await hook.VerificationCodeResetPassword(record);
|
||||
await hook.SendVerificationCode(record);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<bool> SendVerificationCodeResetPasswordLogin()
|
||||
public async Task<bool> SendVerificationCodeLogin()
|
||||
{
|
||||
var db = _services.GetRequiredService<IBotSharpRepository>();
|
||||
|
||||
|
|
@ -652,7 +653,7 @@ public class UserService : IUserService
|
|||
var hooks = _services.GetServices<IAuthenticationHook>();
|
||||
foreach (var hook in hooks)
|
||||
{
|
||||
await hook.VerificationCodeResetPassword(record);
|
||||
await hook.SendVerificationCode(record);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -132,13 +132,13 @@ public class UserController : ControllerBase
|
|||
[HttpPost("/user/verifycode-out")]
|
||||
public async Task<bool> SendVerificationCodeResetPassword([FromBody] UserCreationModel user)
|
||||
{
|
||||
return await _userService.SendVerificationCodeResetPasswordNoLogin(user.ToUser());
|
||||
return await _userService.SendVerificationCodeNoLogin(user.ToUser());
|
||||
}
|
||||
|
||||
[HttpPost("/user/verifycode-in")]
|
||||
public async Task<bool> SendVerificationCodeResetPasswordLogined()
|
||||
{
|
||||
return await _userService.SendVerificationCodeResetPasswordLogin();
|
||||
return await _userService.SendVerificationCodeLogin();
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
|
|
|
|||
Loading…
Reference in a new issue