mirror of https://github.com/halo-dev/halo
Fix the problem of ServerHttpResponse already committed after logging in (#3658)
#### What type of PR is this? /kind bug /area core #### What this PR does / why we need it: Move `defaultHandler#onAuthenticationSuccess` up to response write, or it will be executed always. #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/3553 #### Special notes for your reviewer: Try to login and see the log detail. #### Does this PR introduce a user-facing change? ```release-note 修复登录成功或失败后报错的问题 ```pull/3668/head^2
parent
03f7e583f6
commit
14d7175443
|
@ -113,6 +113,10 @@ public class UsernamePasswordAuthenticator implements AdditionalWebFilter {
|
||||||
return ignoringMediaTypeAll(MediaType.APPLICATION_JSON)
|
return ignoringMediaTypeAll(MediaType.APPLICATION_JSON)
|
||||||
.matches(webFilterExchange.getExchange())
|
.matches(webFilterExchange.getExchange())
|
||||||
.filter(ServerWebExchangeMatcher.MatchResult::isMatch)
|
.filter(ServerWebExchangeMatcher.MatchResult::isMatch)
|
||||||
|
.switchIfEmpty(
|
||||||
|
defaultHandler.onAuthenticationSuccess(webFilterExchange, authentication)
|
||||||
|
.then(Mono.empty())
|
||||||
|
)
|
||||||
.flatMap(matchResult -> {
|
.flatMap(matchResult -> {
|
||||||
var principal = authentication.getPrincipal();
|
var principal = authentication.getPrincipal();
|
||||||
if (principal instanceof CredentialsContainer credentialsContainer) {
|
if (principal instanceof CredentialsContainer credentialsContainer) {
|
||||||
|
@ -124,10 +128,7 @@ public class UsernamePasswordAuthenticator implements AdditionalWebFilter {
|
||||||
.bodyValue(principal)
|
.bodyValue(principal)
|
||||||
.flatMap(serverResponse ->
|
.flatMap(serverResponse ->
|
||||||
serverResponse.writeTo(webFilterExchange.getExchange(), context));
|
serverResponse.writeTo(webFilterExchange.getExchange(), context));
|
||||||
})
|
});
|
||||||
.switchIfEmpty(
|
|
||||||
defaultHandler.onAuthenticationSuccess(webFilterExchange, authentication)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue