1
This commit is contained in:
@@ -22,7 +22,7 @@ cd /root/project/acme/acme.sh
|
|||||||
--reloadcmd "docker restart openresty"
|
--reloadcmd "docker restart openresty"
|
||||||
|
|
||||||
# 3. 验证
|
# 3. 验证
|
||||||
echo "--- 证书文件 ---"
|
echo "--- 证书文件 ---"1
|
||||||
ls -l /opt/1panel/apps/openresty/openresty/www/common/ssl/
|
ls -l /opt/1panel/apps/openresty/openresty/www/common/ssl/
|
||||||
ls -l /opt/1panel/apps/openresty/openresty/www/common/ssl/jarvis.van333.cn/ 2>/dev/null || true
|
ls -l /opt/1panel/apps/openresty/openresty/www/common/ssl/jarvis.van333.cn/ 2>/dev/null || true
|
||||||
echo "--- 证书过期时间 ---"
|
echo "--- 证书过期时间 ---"
|
||||||
|
|||||||
@@ -167,11 +167,14 @@ public class WPS365CallbackController extends BaseController {
|
|||||||
tokenInfo.getUserId(),
|
tokenInfo.getUserId(),
|
||||||
tokenInfo.getAccessToken() != null ? tokenInfo.getAccessToken().substring(0, 20) + "..." : "null");
|
tokenInfo.getAccessToken() != null ? tokenInfo.getAccessToken().substring(0, 20) + "..." : "null");
|
||||||
|
|
||||||
// 自动保存token到后端
|
// 自动保存token到后端(用 WPS 返回的 userId 存一份,再用 default_user 存一份,便于前端固定用 default_user 查询)
|
||||||
try {
|
try {
|
||||||
if (tokenInfo.getUserId() != null) {
|
if (tokenInfo.getUserId() != null) {
|
||||||
wps365OAuthService.saveToken(tokenInfo.getUserId(), tokenInfo);
|
wps365OAuthService.saveToken(tokenInfo.getUserId(), tokenInfo);
|
||||||
log.info("访问令牌已自动保存到后端缓存 - userId: {}", tokenInfo.getUserId());
|
log.info("访问令牌已自动保存到后端缓存 - userId: {}", tokenInfo.getUserId());
|
||||||
|
// 同时以 default_user 保存,前端 WPS365 页固定传 userId=default_user,否则会提示未授权
|
||||||
|
wps365OAuthService.saveToken("default_user", tokenInfo);
|
||||||
|
log.info("已同时保存为 default_user,前端可直接使用");
|
||||||
} else {
|
} else {
|
||||||
log.warn("userId为空,无法保存Token");
|
log.warn("userId为空,无法保存Token");
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
|||||||
@@ -108,18 +108,24 @@ public class WPS365Controller extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前用户的Token状态
|
* 获取当前用户的Token状态
|
||||||
|
* 前端 WPS365 页固定传 userId=default_user;若该 key 下无 token,则尝试用任意已存 token 并写回 default_user,避免“已授权却提示未授权”
|
||||||
*/
|
*/
|
||||||
@GetMapping("/tokenStatus")
|
@GetMapping("/tokenStatus")
|
||||||
public AjaxResult getTokenStatus(@RequestParam(required = false) String userId) {
|
public AjaxResult getTokenStatus(@RequestParam(required = false) String userId) {
|
||||||
try {
|
try {
|
||||||
WPS365TokenInfo tokenInfo = null;
|
WPS365TokenInfo tokenInfo = null;
|
||||||
|
|
||||||
// 如果提供了userId,查询指定用户的token
|
|
||||||
if (userId != null && !userId.trim().isEmpty()) {
|
if (userId != null && !userId.trim().isEmpty()) {
|
||||||
tokenInfo = wps365OAuthServiceImpl.getTokenByUserId(userId);
|
tokenInfo = wps365OAuthServiceImpl.getTokenByUserId(userId);
|
||||||
|
// 前端固定用 default_user,但回调可能只存了 WPS 返回的 userId(如 wps365_xxx),此处兜底:用任意已存 token 并写回 default_user
|
||||||
|
if (tokenInfo == null && "default_user".equals(userId)) {
|
||||||
|
tokenInfo = wps365OAuthService.getCurrentToken();
|
||||||
|
if (tokenInfo != null) {
|
||||||
|
wps365OAuthService.saveToken("default_user", tokenInfo);
|
||||||
|
log.info("已用已有 WPS365 Token 补写 default_user,前端可正常显示已授权");
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 如果没有提供userId,尝试查找所有token(通常只有一个)
|
|
||||||
// 这里使用getCurrentToken方法,它会尝试查找可用的token
|
|
||||||
tokenInfo = wps365OAuthService.getCurrentToken();
|
tokenInfo = wps365OAuthService.getCurrentToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user