|
3 | 3 | import cn.hutool.core.util.StrUtil; |
4 | 4 | import com.google.code.kaptcha.impl.DefaultKaptcha; |
5 | 5 | import com.hackyle.blog.admin.infrastructure.holder.AuthedContextHolder; |
| 6 | +import com.hackyle.blog.admin.infrastructure.redis.CacheKey; |
6 | 7 | import com.hackyle.blog.admin.module.auth.model.dto.LoginDto; |
7 | 8 | import com.hackyle.blog.admin.module.auth.model.dto.UserDetailsDto; |
8 | 9 | import com.hackyle.blog.admin.module.auth.model.vo.CaptchaVo; |
@@ -50,8 +51,9 @@ public class AuthServiceImpl implements AuthService { |
50 | 51 |
|
51 | 52 | @Override |
52 | 53 | public LoginVo login(LoginDto loginDto) { |
53 | | - String cacheCode = (String) redisTemplate.opsForValue().get(loginDto.getUuid()); |
54 | | - redisTemplate.delete(loginDto.getUuid()); // 清除验证码 |
| 54 | + String key = CacheKey.Auth.CAPTCHA+loginDto.getUuid(); |
| 55 | + String cacheCode = (String) redisTemplate.opsForValue().get(key); |
| 56 | + redisTemplate.delete(key); // 清除验证码 |
55 | 57 | if (StringUtils.isBlank(cacheCode)) { |
56 | 58 | throw new IllegalArgumentException("验证码不存在或已过期"); |
57 | 59 | } |
@@ -109,7 +111,7 @@ public CaptchaVo captcha() { |
109 | 111 | String uuid = UUID.randomUUID().toString(); |
110 | 112 | captchaVo.setUuid(uuid); |
111 | 113 | captchaVo.setCode("data:image/png;base64," + base64Code); |
112 | | - redisTemplate.opsForValue().set(uuid, kaptchaText, 60L, TimeUnit.SECONDS); |
| 114 | + redisTemplate.opsForValue().set(CacheKey.Auth.CAPTCHA+uuid, kaptchaText, 60L, TimeUnit.SECONDS); |
113 | 115 |
|
114 | 116 | return captchaVo; |
115 | 117 | } |
|
0 commit comments