MEMBER:修改密码时,发送验证码无需传递 mobile,通过 user 查询

This commit is contained in:
YunaiV 2023-12-17 23:46:48 +08:00
parent e59f43408c
commit b4612262b3
3 changed files with 10 additions and 4 deletions

View File

@ -60,14 +60,14 @@ public class AppMemberUserController {
@PutMapping("/update-password")
@Operation(summary = "修改用户密码", description = "用户修改密码时使用")
@PreAuthenticated
public CommonResult<Boolean> updatePassword(@RequestBody @Valid AppMemberUserUpdatePasswordReqVO reqVO) {
public CommonResult<Boolean> updateUserPassword(@RequestBody @Valid AppMemberUserUpdatePasswordReqVO reqVO) {
userService.updateUserPassword(getLoginUserId(), reqVO);
return success(true);
}
@PutMapping("/reset-password")
@Operation(summary = "重置密码", description = "用户忘记密码时使用")
public CommonResult<Boolean> resetPassword(@RequestBody @Valid AppMemberUserResetPasswordReqVO reqVO) {
public CommonResult<Boolean> resetUserPassword(@RequestBody @Valid AppMemberUserResetPasswordReqVO reqVO) {
userService.resetUserPassword(reqVO);
return success(true);
}

View File

@ -214,11 +214,17 @@ public class MemberAuthServiceImpl implements MemberAuthService {
}
// 情况 2如果是重置密码场景需要校验手机号是存在的
if (Objects.equals(reqVO.getScene(), SmsSceneEnum.MEMBER_RESET_PASSWORD.getScene())) {
MemberUserDO user= userService.getUserByMobile(reqVO.getMobile());
MemberUserDO user = userService.getUserByMobile(reqVO.getMobile());
if (user == null) {
throw exception(USER_MOBILE_NOT_EXISTS);
}
}
// 情况 3如果是修改密码场景需要查询手机号无需前端传递
if (Objects.equals(reqVO.getScene(), SmsSceneEnum.MEMBER_UPDATE_PASSWORD.getScene())) {
MemberUserDO user = userService.getUser(userId);
// TODO 芋艿后续 member user 手机非强绑定这块需要做下调整
reqVO.setMobile(user.getMobile());
}
// 执行发送
smsCodeApi.sendSmsCode(AuthConvert.INSTANCE.convert(reqVO).setCreateIp(getClientIP()));

View File

@ -18,7 +18,7 @@ public enum SmsSceneEnum implements IntArrayValuable {
MEMBER_LOGIN(1, "user-sms-login", "会员用户 - 手机号登陆"),
MEMBER_UPDATE_MOBILE(2, "user-update-mobile", "会员用户 - 修改手机"),
MEMBER_UPDATE_PASSWORD(3, "user-update-mobile", "会员用户 - 修改密码"),
MEMBER_UPDATE_PASSWORD(3, "user-update-password", "会员用户 - 修改密码"),
MEMBER_RESET_PASSWORD(4, "user-reset-password", "会员用户 - 忘记密码"),
ADMIN_MEMBER_LOGIN(21, "admin-sms-login", "后台用户 - 手机号登录");