Add support for specifying the screen after require_registration

Also use it in start chat and join group

Signed-off-by: Stuart Mumford <stuart@cadair.com>
pull/21833/head
Stuart Mumford 2020-01-12 17:15:19 +00:00
parent 2c6045fe9f
commit 32eb2c13bf
No known key found for this signature in database
GPG Key ID: 60BC5C03E6276769
3 changed files with 15 additions and 4 deletions

View File

@ -39,6 +39,8 @@ export const SAFE_LOCALPART_REGEX = /^[a-z0-9=_\-./]+$/;
* If true, goes to the home page if the user cancels the action * If true, goes to the home page if the user cancels the action
* @param {bool} options.go_welcome_on_cancel * @param {bool} options.go_welcome_on_cancel
* If true, goes to the welcome page if the user cancels the action * If true, goes to the welcome page if the user cancels the action
* @param {bool} options.screen_after
* If present the screen to redict to after a successful login or register.
*/ */
export async function startAnyRegistrationFlow(options) { export async function startAnyRegistrationFlow(options) {
if (options === undefined) options = {}; if (options === undefined) options = {};
@ -72,13 +74,15 @@ export async function startAnyRegistrationFlow(options) {
button: _t("Register"), button: _t("Register"),
extraButtons: [ extraButtons: [
<button className="mx_Dialog_primary" <button className="mx_Dialog_primary"
onClick={() => {modal.close(); dis.dispatch({action: 'start_login'});}}> onClick={() => {modal.close(); dis.dispatch({action: 'start_login',
screenAfterLogin: options.screen_after});}}>
{ _t('Login') } { _t('Login') }
</button>, </button>,
], ],
onFinished: (proceed) => { onFinished: (proceed) => {
if (proceed) { if (proceed) {
dis.dispatch({action: 'start_registration'}); dis.dispatch({action: 'start_registration',
screenAfterLogin: options.screen_after});
} else if (options.go_home_on_cancel) { } else if (options.go_home_on_cancel) {
dis.dispatch({action: 'view_home_page'}); dis.dispatch({action: 'view_home_page'});
} else if (options.go_welcome_on_cancel) { } else if (options.go_welcome_on_cancel) {

View File

@ -481,7 +481,8 @@ export default createReactClass({
group_id: groupId, group_id: groupId,
}, },
}); });
dis.dispatch({action: 'require_registration'}); dis.dispatch({action: 'require_registration',
screen_after: {screen: `group/${groupId}`}});
willDoOnboarding = true; willDoOnboarding = true;
} }
if (stateKey === GroupStore.STATE_KEY.Summary) { if (stateKey === GroupStore.STATE_KEY.Summary) {
@ -726,7 +727,8 @@ export default createReactClass({
_onJoinClick: async function() { _onJoinClick: async function() {
if (this._matrixClient.isGuest()) { if (this._matrixClient.isGuest()) {
dis.dispatch({action: 'require_registration'}); dis.dispatch({action: 'require_registration',
screen_after: {screen: `group/${this.props.groupId}`}});
return; return;
} }

View File

@ -1008,6 +1008,11 @@ export default createReactClass({
// needs to be reset so that they can revisit /user/.. // (and trigger // needs to be reset so that they can revisit /user/.. // (and trigger
// `_chatCreateOrReuse` again) // `_chatCreateOrReuse` again)
go_welcome_on_cancel: true, go_welcome_on_cancel: true,
screen_after: {screen: `user/${this.props.config.welcomeUserId}`,
params: {
action: 'chat'
}
}
}); });
return; return;
} }