优化token获取

This commit is contained in:
zhouhao
2022-04-06 21:15:23 +08:00
parent 6d486b6b3b
commit 7f95784e5b
3 changed files with 8 additions and 12 deletions

View File

@@ -47,8 +47,8 @@ public class ReactiveUserTokenController {
@Authorize(merge = false)
@Operation(summary = "重置当前用户的令牌")
public Mono<Boolean> resetToken() {
return ContextUtils.reactiveContext()
.map(context -> context.get(ContextKey.of(ParsedToken.class)).orElseThrow(UnAuthorizedException::new))
return Mono
.<ParsedToken>deferWithContext(ctx -> Mono.justOrEmpty(ctx.getOrEmpty(ParsedToken.class)))
.flatMap(token -> userTokenManager.signOutByToken(token.getToken()))
.thenReturn(true);
}