wei.zhang2 2017-12-29 15:08:46 +08:00
parent 69d3f3c48f
commit 68d9aa8a89
2 changed files with 17 additions and 17 deletions

View File

@ -108,10 +108,10 @@ public class TokenServiceDbImpl implements TokenService {
}
@Override
public LoginUser getLoginUser(String token) {
String string = getUUIDFromJWT(token);
if (string != null) {
TokenModel model = tokenDao.getById(string);
public LoginUser getLoginUser(String jwtToken) {
String uuid = getUUIDFromJWT(jwtToken);
if (uuid != null) {
TokenModel model = tokenDao.getById(uuid);
return toLoginUser(model);
}
@ -119,13 +119,13 @@ public class TokenServiceDbImpl implements TokenService {
}
@Override
public boolean deleteToken(String token) {
String string = getUUIDFromJWT(token);
if (string != null) {
TokenModel model = tokenDao.getById(string);
public boolean deleteToken(String jwtToken) {
String uuid = getUUIDFromJWT(jwtToken);
if (uuid != null) {
TokenModel model = tokenDao.getById(uuid);
LoginUser loginUser = toLoginUser(model);
if (loginUser != null) {
tokenDao.delete(token);
tokenDao.delete(uuid);
logService.save(loginUser.getId(), "退出", true, null);
return true;

View File

@ -103,9 +103,9 @@ public class TokenServiceJWTImpl implements TokenService {
@Override
public LoginUser getLoginUser(String jwtToken) {
String string = getUUIDFromJWT(jwtToken);
if (string != null) {
return redisTemplate.boundValueOps(getTokenKey(string)).get();
String uuid = getUUIDFromJWT(jwtToken);
if (uuid != null) {
return redisTemplate.boundValueOps(getTokenKey(uuid)).get();
}
return null;
@ -113,9 +113,9 @@ public class TokenServiceJWTImpl implements TokenService {
@Override
public boolean deleteToken(String jwtToken) {
String string = getUUIDFromJWT(jwtToken);
if (string != null) {
String key = getTokenKey(string);
String uuid = getUUIDFromJWT(jwtToken);
if (uuid != null) {
String key = getTokenKey(uuid);
LoginUser loginUser = redisTemplate.opsForValue().get(key);
if (loginUser != null) {
redisTemplate.delete(key);
@ -129,8 +129,8 @@ public class TokenServiceJWTImpl implements TokenService {
return false;
}
private String getTokenKey(String token) {
return "tokens:" + token;
private String getTokenKey(String uuid) {
return "tokens:" + uuid;
}
private Key getKeyInstance() {