问题修复

This commit is contained in:
zhangchenbiao
2023-07-20 09:43:51 +08:00
parent 368e4757c3
commit 5a74bb43c7
12 changed files with 44 additions and 29 deletions

View File

@@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.MessageFormat;
import java.util.Objects;
/**
@@ -78,12 +79,10 @@ public class LoginServiceImpl implements LoginService {
//生成令牌
RandomNumberGenerator randomNumberGenerator = new SecureRandomNumberGenerator();
String token = randomNumberGenerator.nextBytes().toHex();
String refreshToken = randomNumberGenerator.nextBytes().toHex();
currentUser.setName(enterpriseUser.getName());
currentUser.setAccessToken(token);
redisUtilPool.setString(CommonConstants.ACCESS_TOKEN_KEY + ":" + token, JSON.toJSONString(currentUser), CommonConstants.ACCESS_TOKEN_EXPIRE);
redisUtilPool.setString(MessageFormat.format(CommonConstants.ACCESS_TOKEN_KEY, token), JSON.toJSONString(currentUser), CommonConstants.ACCESS_TOKEN_EXPIRE);
redisUtilPool.setString(currentUser.getUserId(), token);
redisUtilPool.setString(CommonConstants.REFRESH_TOKEN_KEY+":"+refreshToken,JSON.toJSONString(refreshUser), CommonConstants.REFRESH_TOKEN_EXPIRE);
log.info("[" + enterpriseUser.getName() + "; action_token"+ token + "; userId" + currentUser.getUserId() +"]登入系统成功");
return currentUser;
}