Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 1f719b3

Browse files
committed
Avoid getting stuck in a loop in CAS login
498ea53 made it so that the #/login URL fragment was prioritised over the token params in the query string; unfortunately that also means that CAS login gets stuck in a loop where you always get redirected back to the login view. Prioritising the URL fragment over the token params may or may not be the correct thing to, but I also think it's incorrect that we ask the CAS server to redirect us back to #/login. Accordingly, the easiest fix here is just to clear the URL fragment before redirecting to CAS.
1 parent 3b23fc7 commit 1f719b3

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/Login.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,18 @@ export default class Login {
178178
}
179179

180180
redirectToCas() {
181-
var client = this._createTemporaryClient();
182-
var parsedUrl = url.parse(window.location.href, true);
181+
const client = this._createTemporaryClient();
182+
const parsedUrl = url.parse(window.location.href, true);
183+
184+
// XXX: at this point, the fragment will always be #/login, which is no
185+
// use to anyone. Ideally, we would get the intended fragment from
186+
// MatrixChat.screenAfterLogin so that you could follow #/room links etc
187+
// through a CAS login.
188+
parsedUrl.hash = "";
189+
183190
parsedUrl.query["homeserver"] = client.getHomeserverUrl();
184191
parsedUrl.query["identityServer"] = client.getIdentityServerUrl();
185-
var casUrl = client.getCasLoginUrl(url.format(parsedUrl));
192+
const casUrl = client.getCasLoginUrl(url.format(parsedUrl));
186193
window.location.href = casUrl;
187194
}
188195
}

0 commit comments

Comments
 (0)