Add support for ${path} in auth.switch_account_url

Provide client-side interpolation of ${path} in this string when
generating the "Switch account" link.

This change also updates the GWT version of this link to simply
remove any ${path} elements. There doesn't seem to be a good way
to ensure the path would be updated as the location changes.

Bug: Issue 4884
Change-Id: I2070208b540efb3f9fb527e23dbbd220fc2d2dce
This commit is contained in:
Logan Hanks
2017-03-16 14:12:23 -07:00
parent ab2fa7cc39
commit 71d1ffd580
4 changed files with 89 additions and 10 deletions

View File

@@ -52,8 +52,9 @@ public class UserPopupPanel extends PopupPanel {
userEmail.setText(account.email());
}
if (showSettingsLink) {
if (Gerrit.info().auth().switchAccountUrl() != null) {
switchAccount.setHref(Gerrit.info().auth().switchAccountUrl());
String switchAccountUrl = Gerrit.info().auth().switchAccountUrl();
if (switchAccountUrl != null) {
switchAccount.setHref(switchAccountUrl.replace("${path}", "/"));
} else if (Gerrit.info().auth().isDev() || Gerrit.info().auth().isOpenId()) {
switchAccount.setHref(Gerrit.selfRedirect("/login"));
} else {