mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2025-09-08 21:37:42 +00:00
add 增加 验证码短信发送接口 与 完善短信登录逻辑
This commit is contained in:
@@ -48,12 +48,12 @@ public class TokenController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 短信登录(示例)
|
||||
* 短信登录
|
||||
*
|
||||
* @param smsLoginBody 登录信息
|
||||
* @return 结果
|
||||
*/
|
||||
@ApiOperation("短信登录(示例)")
|
||||
@ApiOperation("短信登录")
|
||||
@PostMapping("/smsLogin")
|
||||
public R<Map<String, Object>> smsLogin(@Validated @RequestBody SmsLoginBody smsLoginBody) {
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
|
@@ -9,6 +9,7 @@ import com.ruoyi.common.core.constant.Constants;
|
||||
import com.ruoyi.common.core.enums.DeviceType;
|
||||
import com.ruoyi.common.core.enums.LoginType;
|
||||
import com.ruoyi.common.core.enums.UserType;
|
||||
import com.ruoyi.common.core.exception.user.CaptchaExpireException;
|
||||
import com.ruoyi.common.core.exception.user.UserException;
|
||||
import com.ruoyi.common.core.utils.MessageUtils;
|
||||
import com.ruoyi.common.core.utils.ServletUtils;
|
||||
@@ -130,8 +131,12 @@ public class SysLoginService {
|
||||
* 校验短信验证码
|
||||
*/
|
||||
private boolean validateSmsCode(String phonenumber, String smsCode) {
|
||||
// todo 此处使用手机号查询redis验证码与参数验证码是否一致 用户自行实现
|
||||
return true;
|
||||
String code = RedisUtils.getCacheObject(Constants.CAPTCHA_CODE_KEY + phonenumber);
|
||||
if (StringUtils.isNotBlank(code)) {
|
||||
recordLogininfor(phonenumber, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"));
|
||||
throw new CaptchaExpireException();
|
||||
}
|
||||
return code.equals(smsCode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user