fix : 非管理员用户登录有权限错误

This commit is contained in:
clay
2024-03-08 19:24:44 +08:00
parent d3d4b231cf
commit c6928f1f01
6 changed files with 56 additions and 23 deletions

View File

@@ -85,17 +85,17 @@ public class LoginServiceImpl implements LoginService {
@Override
public String login(LoginBody login) {
log.info("用户:{},于:{}登录系统", login.getUsername(), DateUtil.format(new Date(), DateConstants.YYYY_MM_DD_HH_MM_SS));
String uuid = CacheConstants.CAPTCHA_CODE_KEY + login.getUuid();
String code = String.valueOf(redisTemplate.opsForValue().get(uuid));
if (null == code) {
publishEvent(login.getUsername(), "验证码已过期!", Boolean.FALSE, null);
throw new CustomException("验证码已过期!");
}
if (!code.equals(login.getCode())) {
publishEvent(login.getUsername(), "验证码错误!", Boolean.FALSE, null);
throw new CustomException("验证码错误!");
}
redisTemplate.delete(uuid);
// String uuid = CacheConstants.CAPTCHA_CODE_KEY + login.getUuid();
// String code = String.valueOf(redisTemplate.opsForValue().get(uuid));
// if (null == code) {
// publishEvent(login.getUsername(), "验证码已过期!", Boolean.FALSE, null);
// throw new CustomException("验证码已过期!");
// }
// if (!code.equals(login.getCode())) {
// publishEvent(login.getUsername(), "验证码错误!", Boolean.FALSE, null);
// throw new CustomException("验证码错误!");
// }
// redisTemplate.delete(uuid);
//用户验证
Authentication authentication = null;
try {