Welcome page, support $ssoUrl and $casUrl placeholders
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>pull/21833/head
parent
548e918437
commit
db6f88c66a
|
@ -37,6 +37,8 @@ export default class EmbeddedPage extends React.PureComponent {
|
||||||
className: PropTypes.string,
|
className: PropTypes.string,
|
||||||
// Whether to wrap the page in a scrollbar
|
// Whether to wrap the page in a scrollbar
|
||||||
scrollbar: PropTypes.bool,
|
scrollbar: PropTypes.bool,
|
||||||
|
// Map of keys to replace with values, e.g {$placeholder: "value"}
|
||||||
|
replaceMap: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
||||||
static contextType = MatrixClientContext;
|
static contextType = MatrixClientContext;
|
||||||
|
@ -81,6 +83,13 @@ export default class EmbeddedPage extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
body = body.replace(/_t\(['"]([\s\S]*?)['"]\)/mg, (match, g1)=>this.translate(g1));
|
body = body.replace(/_t\(['"]([\s\S]*?)['"]\)/mg, (match, g1)=>this.translate(g1));
|
||||||
|
|
||||||
|
if (this.props.replaceMap) {
|
||||||
|
Object.keys(this.props.replaceMap).forEach(key => {
|
||||||
|
body = body.split(key).join(this.props.replaceMap[key]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({ page: body });
|
this.setState({ page: body });
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -2021,7 +2021,7 @@ export default createReactClass({
|
||||||
}
|
}
|
||||||
} else if (this.state.view === VIEWS.WELCOME) {
|
} else if (this.state.view === VIEWS.WELCOME) {
|
||||||
const Welcome = sdk.getComponent('auth.Welcome');
|
const Welcome = sdk.getComponent('auth.Welcome');
|
||||||
view = <Welcome />;
|
view = <Welcome {...this.getServerProperties()} />;
|
||||||
} else if (this.state.view === VIEWS.REGISTER) {
|
} else if (this.state.view === VIEWS.REGISTER) {
|
||||||
const Registration = sdk.getComponent('structures.auth.Registration');
|
const Registration = sdk.getComponent('structures.auth.Registration');
|
||||||
view = (
|
view = (
|
||||||
|
|
|
@ -18,6 +18,7 @@ import React from 'react';
|
||||||
import * as sdk from '../../../index';
|
import * as sdk from '../../../index';
|
||||||
import SdkConfig from '../../../SdkConfig';
|
import SdkConfig from '../../../SdkConfig';
|
||||||
import AuthPage from "./AuthPage";
|
import AuthPage from "./AuthPage";
|
||||||
|
import * as Matrix from "matrix-js-sdk";
|
||||||
|
|
||||||
export default class Welcome extends React.PureComponent {
|
export default class Welcome extends React.PureComponent {
|
||||||
render() {
|
render() {
|
||||||
|
@ -33,11 +34,23 @@ export default class Welcome extends React.PureComponent {
|
||||||
pageUrl = 'welcome.html';
|
pageUrl = 'welcome.html';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const {hsUrl, isUrl} = this.props.serverConfig;
|
||||||
|
const tmpClient = Matrix.createClient({
|
||||||
|
baseUrl: hsUrl,
|
||||||
|
idBaseUrl: isUrl,
|
||||||
|
});
|
||||||
|
const callbackUrl = this.getSSOCallbackUrl(tmpClient.getHomeserverUrl(), tmpClient.getIdentityServerUrl());
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthPage>
|
<AuthPage>
|
||||||
<div className="mx_Welcome">
|
<div className="mx_Welcome">
|
||||||
<EmbeddedPage className="mx_WelcomePage"
|
<EmbeddedPage
|
||||||
|
className="mx_WelcomePage"
|
||||||
url={pageUrl}
|
url={pageUrl}
|
||||||
|
replaceMap={{
|
||||||
|
"$ssoUrl": tmpClient.getSsoLoginUrl(callbackUrl.toString(), "sso"),
|
||||||
|
"$casUrl": tmpClient.getSsoLoginUrl(callbackUrl.toString(), "cas"),
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<LanguageSelector />
|
<LanguageSelector />
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue