|
|
@ -157,20 +157,15 @@ public class AuthServiceImpl implements AuthService { |
|
|
|
throw new RenException(ErrorCode.UNAUTHORIZED); |
|
|
|
} |
|
|
|
//获取用户ID
|
|
|
|
String userId; |
|
|
|
try { |
|
|
|
userId = claims.getSubject(); |
|
|
|
} catch (Exception e) { |
|
|
|
throw new RenException(ErrorCode.PARSING_ERROR, Constant.TOKEN_HEADER); |
|
|
|
} |
|
|
|
String userId = claims.getSubject(); |
|
|
|
//查询Redis,如果没数据,则保持用户信息到Redis
|
|
|
|
TokenDto cpUserDetail = cpUserDetailRedis.get(userId); |
|
|
|
if (cpUserDetail != null) { |
|
|
|
//过期时间
|
|
|
|
long expire = (claims.getExpiration().getTime() - System.currentTimeMillis()) / 1000; |
|
|
|
cpUserDetailRedis.set(cpUserDetail, expire); |
|
|
|
return cpUserDetail; |
|
|
|
if (null == cpUserDetail) { |
|
|
|
throw new RenException(ErrorCode.INVALID_ERROR, Constant.TOKEN_HEADER); |
|
|
|
} |
|
|
|
return null; |
|
|
|
//过期时间
|
|
|
|
long expire = (claims.getExpiration().getTime() - System.currentTimeMillis()) / 1000; |
|
|
|
cpUserDetailRedis.set(cpUserDetail, expire); |
|
|
|
return cpUserDetail; |
|
|
|
} |
|
|
|
} |
|
|
|