| | |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.MessageUtils; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | |
| | | // 登录成功 清空错误次数 |
| | | RedisUtils.deleteObject(Constants.LOGIN_ERROR + username); |
| | | asyncService.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"), request); |
| | | recordLoginInfo(user.getUserId(), username); |
| | | |
| | | LoginUser loginUser = buildLoginUser(user); |
| | | |
| | | // 生成token |
| | | LoginHelper.loginByDevice(loginUser, DeviceType.PC); |
| | | |
| | | asyncService.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"), request); |
| | | recordLoginInfo(user.getUserId(), username); |
| | | return StpUtil.getTokenValue(); |
| | | } |
| | | |
| | | public void logout(String loginName) { |
| | | asyncService.recordLogininfor(loginName, Constants.LOGOUT, MessageUtils.message("user.logout.success"), ServletUtils.getRequest()); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param uuid 唯一标识 |
| | | */ |
| | | public void validateCaptcha(String username, String code, String uuid, HttpServletRequest request) { |
| | | String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid; |
| | | String verifyKey = Constants.CAPTCHA_CODE_KEY + StringUtils.defaultString(uuid, ""); |
| | | String captcha = RedisUtils.getCacheObject(verifyKey); |
| | | RedisUtils.deleteObject(verifyKey); |
| | | if (captcha == null) { |