Skip to content

Commit

Permalink
fix: Signup error redirect to wrong path (#31179)
Browse files Browse the repository at this point in the history
On signup failure, we need to redirect the client to same signup page
they were on, for the error message to show up. So instead of
redirecting to the homepage, we get the path from the incoming request
and use that.
  • Loading branch information
sharat87 committed Feb 16, 2024
1 parent f939d20 commit 712a28e
Showing 1 changed file with 12 additions and 1 deletion.
Expand Up @@ -219,10 +219,21 @@ public Mono<Void> signupAndLoginFromFormData(ServerWebExchange exchange) {
.flatMap(user -> signupAndLogin(user, exchange))
.then()
.onErrorResume(error -> {
String path = "/user/signup";

String referer = exchange.getRequest().getHeaders().getFirst("referer");
if (referer != null) {
try {
path = URI.create(referer).getPath();
} catch (IllegalArgumentException ex) {
// This is okay, we just use the default value for `path`.
}
}

URI redirectUri;
try {
redirectUri = new URIBuilder()
.setPath("/")
.setPath(path)
.setParameter("error", error.getMessage())
.build();
} catch (URISyntaxException e) {
Expand Down

0 comments on commit 712a28e

Please sign in to comment.