parent
41029fd9c3
commit
4f16bc1dcc
|
@ -242,13 +242,15 @@ public class UserAccountCacheManagerImpl implements UserAccountCacheManager {
|
|||
*/
|
||||
@Override
|
||||
public String getUserToken(String username) throws NoSuchAlgorithmException {
|
||||
UserAccountCache uc;
|
||||
|
||||
// 根据用户名在缓存中查找用户
|
||||
Optional<UserAccountCache> findRet = userAccountCache.values().stream()
|
||||
.filter(userAccountCache -> username.equals(userAccountCache.getUsername()))
|
||||
.findFirst();
|
||||
|
||||
if (findRet.isPresent()) {
|
||||
UserAccountCache uc = findRet.get();
|
||||
uc = findRet.get();
|
||||
|
||||
// token过期获取以前没有token,创建一个新token
|
||||
if ((System.currentTimeMillis() - uc.getLastAccess())
|
||||
|
@ -262,10 +264,9 @@ public class UserAccountCacheManagerImpl implements UserAccountCacheManager {
|
|||
|
||||
uc.setLastAccess(System.currentTimeMillis());
|
||||
|
||||
return uc.getToken();
|
||||
} else {
|
||||
// 用户不存在说明没有登陆过,创建一个新的用户缓存
|
||||
UserAccountCache uc = UserAccountCache.builder()
|
||||
uc = UserAccountCache.builder()
|
||||
.username(username)
|
||||
.token(createUserToken(username))
|
||||
.lastAccess(System.currentTimeMillis())
|
||||
|
@ -276,8 +277,8 @@ public class UserAccountCacheManagerImpl implements UserAccountCacheManager {
|
|||
|
||||
log.info("Create {} Token:{}", username, uc.getToken());
|
||||
|
||||
return uc.getToken();
|
||||
}
|
||||
return uc.getToken();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue