Skip to content

Commit

Permalink
Fix the problem of not redirecting to corresponding login page after …
Browse files Browse the repository at this point in the history
…authentication failure (#6896)

#### What type of PR is this?

/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:

This PR appends query `method=local` after redirection location in authentication failure handler to redirect to login page with local method.

#### Which issue(s) this PR fixes:

Fixes #6894

#### Does this PR introduce a user-facing change?

```release-note
修复非默认登录方式登录失败之后跳转至默认登录方式的问题
```
  • Loading branch information
JohnNiang authored Oct 18, 2024
1 parent c465bf8 commit 697a5e5
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ public Mono<Void> onAuthenticationFailure(WebFilterExchange webFilterExchange,
.filter(ServerWebExchangeMatcher.MatchResult::isMatch)
.switchIfEmpty(Mono.defer(
() -> {
URI location = URI.create("/login?error");
URI location = URI.create("/login?error&method=local");
if (exception instanceof BadCredentialsException) {
location = URI.create("/login?error=invalid-credential");
location = URI.create("/login?error=invalid-credential&method=local");
}
if (exception instanceof TooManyRequestsException) {
location = URI.create("/login?error=rate-limit-exceeded");
location = URI.create("/login?error=rate-limit-exceeded&method=local");
}
return redirectStrategy.sendRedirect(exchange, location);
}).then(Mono.empty())
Expand Down

0 comments on commit 697a5e5

Please sign in to comment.