Fix successful login redirection to keep parameters
Login screen accept a token to redirect to on successful login but if the token contained parameters, they were dropped. Encode/decode the token to fix this issue. When a URL has a pound sign, it is included in the token as well. This removes the hardcoded behaviour to include a pound sign in every redirect URL. Will now be able to use login redirection for URLs with no pound sign (e.g. GitWeb) Change-Id: If8a74a74ce11f79389895e4d036b06a1e81abbe5
This commit is contained in:
@@ -336,7 +336,15 @@ public class Gerrit implements EntryPoint {
|
||||
} else if (token.startsWith("/")) {
|
||||
token = token.substring(1);
|
||||
}
|
||||
return selfRedirect("/login/" + token);
|
||||
|
||||
UrlBuilder builder = new UrlBuilder();
|
||||
builder.setProtocol(Location.getProtocol());
|
||||
builder.setHost(Location.getHost());
|
||||
String port = Location.getPort();
|
||||
if (port != null && !port.isEmpty()) {
|
||||
builder.setPort(Integer.parseInt(port));
|
||||
}
|
||||
return builder.buildString() + ("/login/" + URL.encodePathSegment("#/" + token));
|
||||
}
|
||||
|
||||
public static String selfRedirect(String suffix) {
|
||||
|
Reference in New Issue
Block a user