|
@@ -62,10 +62,15 @@ public class AclService {
|
|
|
verificationLogDao.insert(verificationLog);
|
|
|
}
|
|
|
|
|
|
- public User verifySystem(String token, String fromSystem) {
|
|
|
- User userEntity = null;
|
|
|
+ public User verifySystem(TokenVo tokenVo) {
|
|
|
+ String token = tokenVo.getToken();
|
|
|
+ String fromSystem = tokenVo.getFromSystem();
|
|
|
+ String system = tokenVo.getSystem();
|
|
|
+ // 为不同system生成不同key
|
|
|
+ String key = system + ":" + token;
|
|
|
+ User userEntity;
|
|
|
// 从redis中查询
|
|
|
- userEntity = (User) redisTemplate.opsForValue().get(token);
|
|
|
+ userEntity = (User) redisTemplate.opsForValue().get(key);
|
|
|
if (userEntity != null) {
|
|
|
log.debug("redis查询成功: {}", userEntity);
|
|
|
// 2.1 可以查到用户信息,重置redis中的用户信息,刷新到期时间
|
|
@@ -84,7 +89,10 @@ public class AclService {
|
|
|
userEntity = userDao.getByLoginName(tokenFlagVo.getLoginName());
|
|
|
if (userEntity != null) {
|
|
|
// 仅当用户信息不为空时,将用户信息存入redis
|
|
|
- redisTemplate.opsForValue().set(token, userEntity, timeoutSeconds, TimeUnit.SECONDS);
|
|
|
+ redisTemplate.opsForValue().set(key, userEntity, timeoutSeconds, TimeUnit.SECONDS);
|
|
|
+ // redis保存新token信息,记录登录日志
|
|
|
+ logVerification(tokenVo, userEntity);
|
|
|
+ log.info("{}登录{}", userEntity.getLoginName(), tokenVo.getSystem());
|
|
|
}
|
|
|
// 返回用户信息
|
|
|
return userEntity;
|