Fix Welcome.html URLs

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2020-06-25 21:24:24 +01:00
parent 69c5aecfc7
commit 3524d678f7
2 changed files with 12 additions and 7 deletions

View file

@ -227,6 +227,15 @@ export default abstract class BasePlatform {
return url; return url;
} }
// persist hs url and is url for when the user is returned to the app with the login token
// MUST be called before using URLs from getSSOCallbackUrl, internally called by startSingleSignOn
persistSSODetails(mxClient: MatrixClient) {
localStorage.setItem(HOMESERVER_URL_KEY, mxClient.getHomeserverUrl());
if (mxClient.getIdentityServerUrl()) {
localStorage.setItem(ID_SERVER_URL_KEY, mxClient.getIdentityServerUrl());
}
}
/** /**
* Begin Single Sign On flows. * Begin Single Sign On flows.
* @param {MatrixClient} mxClient the matrix client using which we should start the flow * @param {MatrixClient} mxClient the matrix client using which we should start the flow
@ -234,11 +243,7 @@ export default abstract class BasePlatform {
* @param {string} fragmentAfterLogin the hash to pass to the app during sso callback. * @param {string} fragmentAfterLogin the hash to pass to the app during sso callback.
*/ */
startSingleSignOn(mxClient: MatrixClient, loginType: "sso" | "cas", fragmentAfterLogin: string) { startSingleSignOn(mxClient: MatrixClient, loginType: "sso" | "cas", fragmentAfterLogin: string) {
// persist hs url and is url for when the user is returned to the app with the login token this.persistSSODetails(mxClient);
localStorage.setItem(HOMESERVER_URL_KEY, mxClient.getHomeserverUrl());
if (mxClient.getIdentityServerUrl()) {
localStorage.setItem(ID_SERVER_URL_KEY, mxClient.getIdentityServerUrl());
}
const callbackUrl = this.getSSOCallbackUrl(fragmentAfterLogin); const callbackUrl = this.getSSOCallbackUrl(fragmentAfterLogin);
window.location.href = mxClient.getSsoLoginUrl(callbackUrl.toString(), loginType); // redirect to SSO window.location.href = mxClient.getSsoLoginUrl(callbackUrl.toString(), loginType); // redirect to SSO
} }

View file

@ -45,8 +45,8 @@ export default class Welcome extends React.PureComponent {
idBaseUrl: isUrl, idBaseUrl: isUrl,
}); });
const plaf = PlatformPeg.get(); const plaf = PlatformPeg.get();
const callbackUrl = plaf.getSSOCallbackUrl(tmpClient.getHomeserverUrl(), tmpClient.getIdentityServerUrl(), plaf.persistSSODetails(tmpClient);
this.props.fragmentAfterLogin); const callbackUrl = plaf.getSSOCallbackUrl(this.props.fragmentAfterLogin);
return ( return (
<AuthPage> <AuthPage>