mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-04-06 10:43:16 +08:00
fix 修复个人信息手机号码参数错误
This commit is contained in:
@@ -54,13 +54,13 @@ public class CaptchaController {
|
|||||||
/**
|
/**
|
||||||
* 发送短信验证码。
|
* 发送短信验证码。
|
||||||
*
|
*
|
||||||
* @param phonenumber 用户手机号
|
* @param phoneNumber 用户手机号
|
||||||
* @return 操作结果
|
* @return 操作结果
|
||||||
*/
|
*/
|
||||||
@RateLimiter(key = "#phonenumber", time = 60, count = 1)
|
@RateLimiter(key = "#phonenumber", time = 60, count = 1)
|
||||||
@GetMapping("/resource/sms/code")
|
@GetMapping("/resource/sms/code")
|
||||||
public R<Void> smsCode(@NotBlank(message = "{user.phonenumber.not.blank}") String phonenumber) {
|
public R<Void> smsCode(@NotBlank(message = "{user.phonenumber.not.blank}") String phoneNumber) {
|
||||||
String key = GlobalConstants.CAPTCHA_CODE_KEY + phonenumber;
|
String key = GlobalConstants.CAPTCHA_CODE_KEY + phoneNumber;
|
||||||
String code = RandomUtil.randomNumbers(4);
|
String code = RandomUtil.randomNumbers(4);
|
||||||
RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
|
RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
|
||||||
// 验证码模板id 自行处理 (查数据库或写死均可)
|
// 验证码模板id 自行处理 (查数据库或写死均可)
|
||||||
@@ -68,7 +68,7 @@ public class CaptchaController {
|
|||||||
LinkedHashMap<String, String> map = new LinkedHashMap<>(1);
|
LinkedHashMap<String, String> map = new LinkedHashMap<>(1);
|
||||||
map.put("code", code);
|
map.put("code", code);
|
||||||
SmsBlend smsBlend = SmsFactory.getSmsBlend("config1");
|
SmsBlend smsBlend = SmsFactory.getSmsBlend("config1");
|
||||||
SmsResponse smsResponse = smsBlend.sendMessage(phonenumber, templateId, map);
|
SmsResponse smsResponse = smsBlend.sendMessage(phoneNumber, templateId, map);
|
||||||
if (!smsResponse.isSuccess()) {
|
if (!smsResponse.isSuccess()) {
|
||||||
log.error("验证码短信发送异常 => {}", smsResponse);
|
log.error("验证码短信发送异常 => {}", smsResponse);
|
||||||
return R.fail(smsResponse.getData().toString());
|
return R.fail(smsResponse.getData().toString());
|
||||||
|
|||||||
@@ -53,10 +53,10 @@ public class SmsAuthStrategy implements IAuthStrategy {
|
|||||||
public LoginVo login(String body, SysClientVo client) {
|
public LoginVo login(String body, SysClientVo client) {
|
||||||
SmsLoginBody loginBody = JsonUtils.parseObject(body, SmsLoginBody.class);
|
SmsLoginBody loginBody = JsonUtils.parseObject(body, SmsLoginBody.class);
|
||||||
ValidatorUtils.validate(loginBody);
|
ValidatorUtils.validate(loginBody);
|
||||||
String phonenumber = loginBody.getPhonenumber();
|
String phoneNumber = loginBody.getPhoneNumber();
|
||||||
String smsCode = loginBody.getSmsCode();
|
String smsCode = loginBody.getSmsCode();
|
||||||
SysUserVo user = loadUserByPhonenumber(phonenumber);
|
SysUserVo user = loadUserByPhoneNumber(phoneNumber);
|
||||||
loginService.checkLogin(LoginType.SMS, user.getUserName(), () -> !validateSmsCode(phonenumber, smsCode));
|
loginService.checkLogin(LoginType.SMS, user.getUserName(), () -> !validateSmsCode(phoneNumber, smsCode));
|
||||||
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
||||||
LoginUser loginUser = loginService.buildLoginUser(user);
|
LoginUser loginUser = loginService.buildLoginUser(user);
|
||||||
loginUser.setClientKey(client.getClientKey());
|
loginUser.setClientKey(client.getClientKey());
|
||||||
@@ -81,14 +81,14 @@ public class SmsAuthStrategy implements IAuthStrategy {
|
|||||||
/**
|
/**
|
||||||
* 校验短信验证码是否存在且匹配。
|
* 校验短信验证码是否存在且匹配。
|
||||||
*
|
*
|
||||||
* @param phonenumber 手机号
|
* @param phoneNumber 手机号
|
||||||
* @param smsCode 用户输入的短信验证码
|
* @param smsCode 用户输入的短信验证码
|
||||||
* @return 是否校验通过
|
* @return 是否校验通过
|
||||||
*/
|
*/
|
||||||
private boolean validateSmsCode(String phonenumber, String smsCode) {
|
private boolean validateSmsCode(String phoneNumber, String smsCode) {
|
||||||
String code = RedisUtils.getCacheObject(GlobalConstants.CAPTCHA_CODE_KEY + phonenumber);
|
String code = RedisUtils.getCacheObject(GlobalConstants.CAPTCHA_CODE_KEY + phoneNumber);
|
||||||
if (StringUtils.isBlank(code)) {
|
if (StringUtils.isBlank(code)) {
|
||||||
loginService.recordLoginInfo(phonenumber, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"));
|
loginService.recordLoginInfo(phoneNumber, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"));
|
||||||
throw new CaptchaExpireException();
|
throw new CaptchaExpireException();
|
||||||
}
|
}
|
||||||
return code.equals(smsCode);
|
return code.equals(smsCode);
|
||||||
@@ -97,17 +97,17 @@ public class SmsAuthStrategy implements IAuthStrategy {
|
|||||||
/**
|
/**
|
||||||
* 按手机号加载可登录用户,并校验是否存在或被停用。
|
* 按手机号加载可登录用户,并校验是否存在或被停用。
|
||||||
*
|
*
|
||||||
* @param phonenumber 手机号
|
* @param phoneNumber 手机号
|
||||||
* @return 用户信息
|
* @return 用户信息
|
||||||
*/
|
*/
|
||||||
private SysUserVo loadUserByPhonenumber(String phonenumber) {
|
private SysUserVo loadUserByPhoneNumber(String phoneNumber) {
|
||||||
SysUserVo user = userMapper.selectVoOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getPhoneNumber, phonenumber));
|
SysUserVo user = userMapper.selectVoOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getPhoneNumber, phoneNumber));
|
||||||
if (ObjectUtil.isNull(user)) {
|
if (ObjectUtil.isNull(user)) {
|
||||||
log.info("登录用户:{} 不存在.", phonenumber);
|
log.info("登录用户:{} 不存在.", phoneNumber);
|
||||||
throw new UserException("user.not.exists", phonenumber);
|
throw new UserException("user.not.exists", phoneNumber);
|
||||||
} else if (SystemConstants.DISABLE.equals(user.getStatus())) {
|
} else if (SystemConstants.DISABLE.equals(user.getStatus())) {
|
||||||
log.info("登录用户:{} 已被停用.", phonenumber);
|
log.info("登录用户:{} 已被停用.", phoneNumber);
|
||||||
throw new UserException("user.blocked", phonenumber);
|
throw new UserException("user.blocked", phoneNumber);
|
||||||
}
|
}
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class UserDTO implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 手机号码
|
* 手机号码
|
||||||
*/
|
*/
|
||||||
private String phonenumber;
|
private String phoneNumber;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户性别(0男 1女 2未知)
|
* 用户性别(0男 1女 2未知)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class SmsLoginBody extends LoginBody {
|
|||||||
* 手机号
|
* 手机号
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "{user.phonenumber.not.blank}")
|
@NotBlank(message = "{user.phonenumber.not.blank}")
|
||||||
private String phonenumber;
|
private String phoneNumber;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 短信code
|
* 短信code
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class ProfileUserVo implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 手机号码
|
* 手机号码
|
||||||
*/
|
*/
|
||||||
private String phonenumber;
|
private String phoneNumber;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户性别(0男 1女 2未知)
|
* 用户性别(0男 1女 2未知)
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class SysUserExportVo implements Serializable {
|
|||||||
* 手机号码
|
* 手机号码
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "手机号码")
|
@ExcelProperty(value = "手机号码")
|
||||||
private String phonenumber;
|
private String phoneNumber;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户性别
|
* 用户性别
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class SysUserImportVo implements Serializable {
|
|||||||
* 手机号码
|
* 手机号码
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "手机号码")
|
@ExcelProperty(value = "手机号码")
|
||||||
private String phonenumber;
|
private String phoneNumber;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户性别
|
* 用户性别
|
||||||
|
|||||||
@@ -63,10 +63,10 @@ public interface ISysUserService {
|
|||||||
/**
|
/**
|
||||||
* 通过手机号查询用户
|
* 通过手机号查询用户
|
||||||
*
|
*
|
||||||
* @param phonenumber 手机号
|
* @param phoneNumber 手机号
|
||||||
* @return 用户对象信息
|
* @return 用户对象信息
|
||||||
*/
|
*/
|
||||||
SysUserVo selectUserByPhonenumber(String phonenumber);
|
SysUserVo selectUserByPhoneNumber(String phoneNumber);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户ID查询用户
|
* 通过用户ID查询用户
|
||||||
|
|||||||
@@ -147,12 +147,12 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
|||||||
/**
|
/**
|
||||||
* 通过手机号查询用户
|
* 通过手机号查询用户
|
||||||
*
|
*
|
||||||
* @param phonenumber 手机号
|
* @param phoneNumber 手机号
|
||||||
* @return 用户对象信息
|
* @return 用户对象信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SysUserVo selectUserByPhonenumber(String phonenumber) {
|
public SysUserVo selectUserByPhoneNumber(String phoneNumber) {
|
||||||
return baseMapper.selectVoOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getPhoneNumber, phonenumber));
|
return baseMapper.selectVoOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getPhoneNumber, phoneNumber));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user