| | |
| | | package com.gkhy.assess.system.service.impl; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.gkhy.assess.common.api.CommonPage; |
| | | import com.gkhy.assess.common.constant.CacheConstant; |
| | |
| | | |
| | | @Override |
| | | public AccountVO login(LoginBody loginBody) { |
| | | // 验证码校验 |
| | | validateCaptcha(loginBody.getUsername(), loginBody.getCode(), loginBody.getUuid()); |
| | | UsernamePasswordToken usernamePasswordToken = new UsernamePasswordToken(loginBody.getUsername(), loginBody.getPassword(), false); |
| | | Subject subject= SecurityUtils.getSubject(); |
| | | String msg ; |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 校验验证码 |
| | | * |
| | | * @param username 用户名 |
| | | * @param code 验证码 |
| | | * @param uuid 唯一标识 |
| | | * @return 结果 |
| | | */ |
| | | public void validateCaptcha(String username, String code, String uuid) |
| | | { |
| | | if(StrUtil.isBlank(code)||StrUtil.isBlank(uuid)){ |
| | | throw new ApiException("验证码或验证码标识为空"); |
| | | } |
| | | String verifyKey = CacheConstant.CAPTCHA_CODE_KEY +uuid; |
| | | String captcha = (String) redisUtils.get(verifyKey); |
| | | redisUtils.del(verifyKey); |
| | | if (StrUtil.isBlank(captcha)) |
| | | { |
| | | throw new ApiException("验证码已失效"); |
| | | } |
| | | if (!code.equalsIgnoreCase(captcha)) |
| | | { |
| | | throw new ApiException("验证码不正确"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void logout() { |
| | | String jwtToken = request.getHeader(JwtTokenUtil.USER_LOGIN_TOKEN); |