fix: add regionCode for ModifyUserPhone API
This commit is contained in:
parent
75bf042507
commit
4b2a94a539
|
|
@ -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<string> userIds, bool isDisable) => throw new NotImplementedException();
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public interface IUserService
|
|||
Task<bool> SendVerificationCodeResetPasswordLogin();
|
||||
Task<bool> ResetUserPassword(User user);
|
||||
Task<bool> ModifyUserEmail(string email);
|
||||
Task<bool> ModifyUserPhone(string phone);
|
||||
Task<bool> ModifyUserPhone(string phone, string regionCode);
|
||||
Task<bool> UpdatePassword(string newPassword, string verificationCode);
|
||||
Task<DateTime> GetUserTokenExpires();
|
||||
Task<bool> UpdateUsersIsDisable(List<string> userIds, bool isDisable);
|
||||
|
|
|
|||
|
|
@ -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<bool> ModifyUserPhone(string phone)
|
||||
public async Task<bool> ModifyUserPhone(string phone, string regionCode)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(regionCode))
|
||||
{
|
||||
throw new Exception("regionCode is required");
|
||||
}
|
||||
var curUser = await GetMyProfile();
|
||||
var db = _services.GetRequiredService<IBotSharpRepository>();
|
||||
var record = db.GetUserById(curUser.Id);
|
||||
|
|
@ -631,6 +635,7 @@ public class UserService : IUserService
|
|||
}
|
||||
|
||||
record.Phone = phone;
|
||||
record.RegionCode = regionCode;
|
||||
|
||||
var hooks = _services.GetServices<IAuthenticationHook>();
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,9 +153,9 @@ public class UserController : ControllerBase
|
|||
}
|
||||
|
||||
[HttpPost("/user/phone/modify")]
|
||||
public async Task<bool> ModifyUserPhone([FromQuery] string phone)
|
||||
public async Task<bool> ModifyUserPhone([FromQuery] string phone, [FromQuery] string regionCode)
|
||||
{
|
||||
return await _userService.ModifyUserPhone(phone);
|
||||
return await _userService.ModifyUserPhone(phone, regionCode);
|
||||
}
|
||||
|
||||
[HttpPost("/user/update/isdisable")]
|
||||
|
|
|
|||
|
|
@ -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<UserDocument>.Filter.Eq(x => x.Id, userId);
|
||||
var update = Builders<UserDocument>.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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue