| | |
| | | import com.ruoyi.company.api.model.RegisterUser; |
| | | import com.ruoyi.system.api.RemoteUserService; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.model.AppUser; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | |
| | | if (l1 - l > 2 * 60 * 1000) { |
| | | throw new CaptchaException("验证码已失效"); |
| | | } |
| | | captcha = split[0]; |
| | | if (!smsCode.equalsIgnoreCase(captcha)) { |
| | | throw new CaptchaException("验证码错误"); |
| | | } |
| | |
| | | if (R.isError(r)) { |
| | | throw new ServiceException(r.getMsg()); |
| | | } |
| | | forceLogout(user.getUserId()); |
| | | } |
| | | |
| | | public void forceLogout(Long userId) { |
| | | Collection<String> keys = redisService.keys(CacheConstants.LOGIN_TOKEN_KEY + "*"); |
| | | for (String key : keys) { |
| | | Object user = redisService.getCacheObject(key); |
| | | if (user instanceof AppUser) { |
| | | AppUser appUser = (AppUser) user; |
| | | if (appUser.getUserId().equals(userId)) { |
| | | redisService.deleteObject(key); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |