Add an optional config option to make the welcome page the login page
This is commonly requested by deployments with custom setups or those using SSO. Instead of having them all ship the same welcome.html with redirect code in it, we can offer a built-in redirect. Note that this doesn't actually redirect and instead just replaces the view. This is to make the change less invasive as otherwise it involves changing the routing layers.
This commit is contained in:
parent
b386f0c73b
commit
21b9ab9d85
2 changed files with 15 additions and 8 deletions
|
@ -82,6 +82,7 @@ import {UIFeature} from "../../settings/UIFeature";
|
||||||
import { CommunityPrototypeStore } from "../../stores/CommunityPrototypeStore";
|
import { CommunityPrototypeStore } from "../../stores/CommunityPrototypeStore";
|
||||||
import DialPadModal from "../views/voip/DialPadModal";
|
import DialPadModal from "../views/voip/DialPadModal";
|
||||||
import { showToast as showMobileGuideToast } from '../../toasts/MobileGuideToast';
|
import { showToast as showMobileGuideToast } from '../../toasts/MobileGuideToast';
|
||||||
|
import { shouldUseLoginForWelcome } from "../../utils/pages";
|
||||||
|
|
||||||
/** constants for MatrixChat.state.view */
|
/** constants for MatrixChat.state.view */
|
||||||
export enum Views {
|
export enum Views {
|
||||||
|
@ -1988,7 +1989,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (this.state.view === Views.WELCOME) {
|
} else if (this.state.view === Views.WELCOME && !shouldUseLoginForWelcome(SdkConfig.get())) {
|
||||||
const Welcome = sdk.getComponent('auth.Welcome');
|
const Welcome = sdk.getComponent('auth.Welcome');
|
||||||
view = <Welcome />;
|
view = <Welcome />;
|
||||||
} else if (this.state.view === Views.REGISTER && SettingsStore.getValue(UIFeature.Registration)) {
|
} else if (this.state.view === Views.REGISTER && SettingsStore.getValue(UIFeature.Registration)) {
|
||||||
|
@ -2020,7 +2021,8 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
{...this.getServerProperties()}
|
{...this.getServerProperties()}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else if (this.state.view === Views.LOGIN) {
|
} else if (this.state.view === Views.LOGIN
|
||||||
|
|| (this.state.view === Views.WELCOME && shouldUseLoginForWelcome(SdkConfig.get()))) {
|
||||||
const showPasswordReset = SettingsStore.getValue(UIFeature.PasswordReset);
|
const showPasswordReset = SettingsStore.getValue(UIFeature.PasswordReset);
|
||||||
const Login = sdk.getComponent('structures.auth.Login');
|
const Login = sdk.getComponent('structures.auth.Login');
|
||||||
view = (
|
view = (
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2019 New Vector Ltd
|
Copyright 2019, 2021 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -14,12 +14,12 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function getHomePageUrl(appConfig) {
|
import { ConfigOptions } from "../SdkConfig";
|
||||||
|
|
||||||
|
export function getHomePageUrl(appConfig: ConfigOptions): string | null {
|
||||||
const pagesConfig = appConfig.embeddedPages;
|
const pagesConfig = appConfig.embeddedPages;
|
||||||
let pageUrl = null;
|
let pageUrl = pagesConfig?.homeUrl;
|
||||||
if (pagesConfig) {
|
|
||||||
pageUrl = pagesConfig.homeUrl;
|
|
||||||
}
|
|
||||||
if (!pageUrl) {
|
if (!pageUrl) {
|
||||||
// This is a deprecated config option for the home page
|
// This is a deprecated config option for the home page
|
||||||
// (despite the name, given we also now have a welcome
|
// (despite the name, given we also now have a welcome
|
||||||
|
@ -29,3 +29,8 @@ export function getHomePageUrl(appConfig) {
|
||||||
|
|
||||||
return pageUrl;
|
return pageUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function shouldUseLoginForWelcome(appConfig: ConfigOptions): boolean {
|
||||||
|
const pagesConfig = appConfig.embeddedPages;
|
||||||
|
return pagesConfig?.loginForWelcome === true;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue