Fix UIFeature.Registration not applying to all paths (#10371)
This commit is contained in:
parent
587da5b7dc
commit
e0e83bd81d
3 changed files with 39 additions and 31 deletions
|
@ -27,6 +27,8 @@ import Modal from "./Modal";
|
|||
import { _t } from "./languageHandler";
|
||||
import QuestionDialog from "./components/views/dialogs/QuestionDialog";
|
||||
import { Action } from "./dispatcher/actions";
|
||||
import SettingsStore from "./settings/SettingsStore";
|
||||
import { UIFeature } from "./settings/UIFeature";
|
||||
|
||||
// Regex for what a "safe" or "Matrix-looking" localpart would be.
|
||||
// TODO: Update as needed for https://github.com/matrix-org/matrix-doc/issues/1514
|
||||
|
@ -46,29 +48,32 @@ export const SAFE_LOCALPART_REGEX = /^[a-z0-9=_\-./]+$/;
|
|||
*/
|
||||
export async function startAnyRegistrationFlow(
|
||||
// eslint-disable-next-line camelcase
|
||||
options: { go_home_on_cancel?: boolean; go_welcome_on_cancel?: boolean; screen_after?: boolean },
|
||||
options: { go_home_on_cancel?: boolean; go_welcome_on_cancel?: boolean; screen_after?: boolean } = {},
|
||||
): Promise<void> {
|
||||
if (options === undefined) options = {};
|
||||
const modal = Modal.createDialog(QuestionDialog, {
|
||||
hasCancelButton: true,
|
||||
quitOnly: true,
|
||||
title: _t("Sign In or Create Account"),
|
||||
description: _t("Use your account or create a new one to continue."),
|
||||
button: _t("Create Account"),
|
||||
extraButtons: [
|
||||
<button
|
||||
key="start_login"
|
||||
onClick={() => {
|
||||
modal.close();
|
||||
dis.dispatch({ action: "start_login", screenAfterLogin: options.screen_after });
|
||||
}}
|
||||
>
|
||||
{_t("Sign In")}
|
||||
</button>,
|
||||
],
|
||||
title: SettingsStore.getValue(UIFeature.Registration) ? _t("Sign In or Create Account") : _t("Sign In"),
|
||||
description: SettingsStore.getValue(UIFeature.Registration)
|
||||
? _t("Use your account or create a new one to continue.")
|
||||
: _t("Use your account to continue."),
|
||||
button: _t("Sign In"),
|
||||
extraButtons: SettingsStore.getValue(UIFeature.Registration)
|
||||
? [
|
||||
<button
|
||||
key="register"
|
||||
onClick={() => {
|
||||
modal.close();
|
||||
dis.dispatch({ action: "start_registration", screenAfterLogin: options.screen_after });
|
||||
}}
|
||||
>
|
||||
{_t("Create Account")}
|
||||
</button>,
|
||||
]
|
||||
: [],
|
||||
onFinished: (proceed) => {
|
||||
if (proceed) {
|
||||
dis.dispatch({ action: "start_registration", screenAfterLogin: options.screen_after });
|
||||
dis.dispatch({ action: "start_login", screenAfterLogin: options.screen_after });
|
||||
} else if (options.go_home_on_cancel) {
|
||||
dis.dispatch({ action: Action.ViewHomePage });
|
||||
} else if (options.go_welcome_on_cancel) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue