Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修正用户是否授权及token是否登记的判断条件 #278

Merged
merged 2 commits into from
Mar 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -21,11 +21,9 @@
import java.time.Duration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.stream.Collectors;

public class RedisUserTokenManager implements UserTokenManager {
@@ -132,12 +130,14 @@ public Flux<UserToken> getByUserId(String userId) {
@Override
public Mono<Boolean> userIsLoggedIn(String userId) {
return getByUserId(userId)
.hasElements();
.any(UserToken::isNormal);
}

@Override
public Mono<Boolean> tokenIsLoggedIn(String token) {
return operations.hasKey(getTokenRedisKey(token));
return getByToken(token)
.map(t -> !t.isExpired())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里为什么不使用 isNormal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

参照了DefaultUserTokenManager里面的判断,方法注释是token是否已登记,所以理解为虽然token无效但是也是平台登记了的?但是方法名又有点歧义,需要改为 isNormal 吗
image

Copy link
Member

@zhou-hao zhou-hao Mar 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按理说应该使用normal。

.defaultIfEmpty(false);
}

@Override