From 404900ee85bfd60dc6c218feb885d3471fad7791 Mon Sep 17 00:00:00 2001 From: caibingfeng <181424167@qq.com> Date: Sat, 12 Oct 2024 10:51:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20redis=E7=BC=93=E5=AD=98=20=20user-token-?= =?UTF-8?q?user=20=20=E8=BF=87=E6=9C=9F=E6=97=B6=E9=97=B4=E8=B7=9F=20user-?= =?UTF-8?q?token=E7=9A=84=E8=BF=87=E6=9C=9F=E6=97=B6=E9=97=B4=E4=B8=80?= =?UTF-8?q?=E8=87=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../token/redis/RedisUserTokenManager.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/token/redis/RedisUserTokenManager.java b/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/token/redis/RedisUserTokenManager.java index 4e7af72a2..a32c733bb 100644 --- a/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/token/redis/RedisUserTokenManager.java +++ b/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/token/redis/RedisUserTokenManager.java @@ -247,7 +247,20 @@ public class RedisUserTokenManager implements UserTokenManager { } return Mono.empty(); })) - .then(userTokenMapping.add(getUserRedisKey(userId), token)) + .then( + Mono.defer(() -> { + String key2 = getUserRedisKey(userId); + return userTokenMapping + .add(key2, token) + .then(Mono.defer(() -> { + if (expires > 0) { + return operations.expire(key2, Duration.ofMillis(expires)); + } + return Mono.empty(); + })); + }) + + ) .thenReturn(SimpleUserToken.of(map)); }); -- Gitee