mirror of https://github.com/vector-im/riot-web
Instead of passing sso and cas urls to Welcome, route via start_sso and start_cas
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>pull/21833/head
parent
1c00ae8dd3
commit
c65ccbcacf
|
@ -18,6 +18,7 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { createRef } from 'react';
|
import React, { createRef } from 'react';
|
||||||
|
import { createClient } from "matrix-js-sdk";
|
||||||
import { InvalidStoreError } from "matrix-js-sdk/src/errors";
|
import { InvalidStoreError } from "matrix-js-sdk/src/errors";
|
||||||
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
||||||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||||
|
@ -1612,6 +1613,19 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
});
|
});
|
||||||
} else if (screen === 'directory') {
|
} else if (screen === 'directory') {
|
||||||
dis.fire(Action.ViewRoomDirectory);
|
dis.fire(Action.ViewRoomDirectory);
|
||||||
|
} else if (screen === "start_sso" || screen === "start_cas") {
|
||||||
|
// TODO if logged in, skip SSO
|
||||||
|
let cli = MatrixClientPeg.get();
|
||||||
|
if (!cli) {
|
||||||
|
const {hsUrl, isUrl} = this.props.serverConfig;
|
||||||
|
cli = createClient({
|
||||||
|
baseUrl: hsUrl,
|
||||||
|
idBaseUrl: isUrl,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const type = screen === "start_sso" ? "sso" : "cas";
|
||||||
|
PlatformPeg.get().startSingleSignOn(cli, type, this.getFragmentAfterLogin());
|
||||||
} else if (screen === 'groups') {
|
} else if (screen === 'groups') {
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'view_my_groups',
|
action: 'view_my_groups',
|
||||||
|
@ -1922,9 +1936,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
this.onLoggedIn();
|
this.onLoggedIn();
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
getFragmentAfterLogin() {
|
||||||
// console.log(`Rendering MatrixChat with view ${this.state.view}`);
|
|
||||||
|
|
||||||
let fragmentAfterLogin = "";
|
let fragmentAfterLogin = "";
|
||||||
if (this.props.initialScreenAfterLogin &&
|
if (this.props.initialScreenAfterLogin &&
|
||||||
// XXX: workaround for https://github.com/vector-im/riot-web/issues/11643 causing a login-loop
|
// XXX: workaround for https://github.com/vector-im/riot-web/issues/11643 causing a login-loop
|
||||||
|
@ -1932,7 +1944,13 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
) {
|
) {
|
||||||
fragmentAfterLogin = `/${this.props.initialScreenAfterLogin.screen}`;
|
fragmentAfterLogin = `/${this.props.initialScreenAfterLogin.screen}`;
|
||||||
}
|
}
|
||||||
|
return fragmentAfterLogin;
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
// console.log(`Rendering MatrixChat with view ${this.state.view}`);
|
||||||
|
|
||||||
|
const fragmentAfterLogin = this.getFragmentAfterLogin();
|
||||||
let view;
|
let view;
|
||||||
|
|
||||||
if (this.state.view === Views.LOADING) {
|
if (this.state.view === Views.LOADING) {
|
||||||
|
@ -2011,7 +2029,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
}
|
}
|
||||||
} 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 {...this.getServerProperties()} fragmentAfterLogin={fragmentAfterLogin} />;
|
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,9 +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";
|
|
||||||
import {_td} from "../../../languageHandler";
|
import {_td} from "../../../languageHandler";
|
||||||
import PlatformPeg from "../../../PlatformPeg";
|
|
||||||
|
|
||||||
// translatable strings for Welcome pages
|
// translatable strings for Welcome pages
|
||||||
_td("Sign in with SSO");
|
_td("Sign in with SSO");
|
||||||
|
@ -39,15 +37,6 @@ 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 plaf = PlatformPeg.get();
|
|
||||||
plaf.persistSSODetails(tmpClient);
|
|
||||||
const callbackUrl = plaf.getSSOCallbackUrl(this.props.fragmentAfterLogin);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthPage>
|
<AuthPage>
|
||||||
<div className="mx_Welcome">
|
<div className="mx_Welcome">
|
||||||
|
@ -55,8 +44,8 @@ export default class Welcome extends React.PureComponent {
|
||||||
className="mx_WelcomePage"
|
className="mx_WelcomePage"
|
||||||
url={pageUrl}
|
url={pageUrl}
|
||||||
replaceMap={{
|
replaceMap={{
|
||||||
"$riot:ssoUrl": tmpClient.getSsoLoginUrl(callbackUrl.toString(), "sso"),
|
"$riot:ssoUrl": "#/start_sso",
|
||||||
"$riot:casUrl": tmpClient.getSsoLoginUrl(callbackUrl.toString(), "cas"),
|
"$riot:casUrl": "#/start_cas",
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<LanguageSelector />
|
<LanguageSelector />
|
||||||
|
|
Loading…
Reference in New Issue