This commit is contained in:
mashuai 2025-05-07 10:23:54 +08:00
parent 0e2fc31463
commit 11d836924c
1 changed files with 8 additions and 3 deletions

View File

@ -125,9 +125,14 @@ public class TokenController {
@PostMapping("sendCode")
public R<?> sendCode(@RequestBody LoginBody form) {
String uuid = form.getUuid();
String captcha = redisService.getCacheObject(CacheConstants.CAPTCHA_CODE_KEY + uuid).toString();
if (StringUtils.isBlank(captcha)) {
return R.fail("验证码超时,请重新刷新");
String captcha = "";
Object object = redisService.getCacheObject(CacheConstants.CAPTCHA_CODE_KEY + uuid);
if (object == null) {
// 删除验证码缓存
redisService.deleteObject(CacheConstants.CAPTCHA_CODE_KEY + uuid);
return R.fail("图形验证码超时,请重新刷新");
} else {
captcha = object.toString();
}
if (form.getCode() != null && !form.getCode().equals(captcha)) {
return R.fail("验证码错误");