Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit e9aac09

Browse files
authored
Merge pull request #1092 from matrix-org/rav/no_resume_client_on_login
Don't create a guest login if user went to /login
2 parents 449c65b + 5d64962 commit e9aac09

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

src/Lifecycle.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ import { _t } from './languageHandler';
3535
* Called at startup, to attempt to build a logged-in Matrix session. It tries
3636
* a number of things:
3737
*
38-
* 0. if it looks like we are in the middle of a registration process, it does
39-
* nothing.
40-
*
4138
* 1. if we have a loginToken in the (real) query params, it uses that to log
4239
* in.
4340
*
@@ -80,14 +77,6 @@ export function loadSession(opts) {
8077
const guestIsUrl = opts.guestIsUrl;
8178
const defaultDeviceDisplayName = opts.defaultDeviceDisplayName;
8279

83-
if (fragmentQueryParams.client_secret && fragmentQueryParams.sid) {
84-
// this happens during email validation: the email contains a link to the
85-
// IS, which in turn redirects back to vector. We let MatrixChat create a
86-
// Registration component which completes the next stage of registration.
87-
console.log("Not registering as guest: registration already in progress.");
88-
return q();
89-
}
90-
9180
if (!guestHsUrl) {
9281
console.warn("Cannot enable guest access: can't determine HS URL to use");
9382
enableGuest = false;

src/components/structures/MatrixChat.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,21 @@ module.exports = React.createClass({
269269
Lifecycle.initRtsClient(this.props.config.teamServerConfig.teamServerURL);
270270
}
271271

272+
// if the user has followed a login or register link, don't reanimate
273+
// the old creds, but rather go straight to the relevant page
274+
275+
const firstScreen = this.state.screenAfterLogin ?
276+
this.state.screenAfterLogin.screen : null;
277+
278+
if (firstScreen === 'login' ||
279+
firstScreen === 'register' ||
280+
firstScreen === 'forgot_password') {
281+
this.props.onLoadCompleted();
282+
this.setState({loading: false});
283+
this._showScreenAfterLogin();
284+
return;
285+
}
286+
272287
// the extra q() ensures that synchronous exceptions hit the same codepath as
273288
// asynchronous ones.
274289
q().then(() => {
@@ -840,14 +855,6 @@ module.exports = React.createClass({
840855
_onLoadCompleted: function() {
841856
this.props.onLoadCompleted();
842857
this.setState({loading: false});
843-
844-
// Show screens (like 'register') that need to be shown without _onLoggedIn
845-
// being called. 'register' needs to be routed here when the email confirmation
846-
// link is clicked on.
847-
if (this.state.screenAfterLogin &&
848-
['register'].indexOf(this.state.screenAfterLogin.screen) !== -1) {
849-
this._showScreenAfterLogin();
850-
}
851858
},
852859

853860
/**
@@ -946,6 +953,7 @@ module.exports = React.createClass({
946953
this.state.screenAfterLogin.screen,
947954
this.state.screenAfterLogin.params,
948955
);
956+
// XXX: is this necessary? `showScreen` should do it for us.
949957
this.notifyNewScreen(this.state.screenAfterLogin.screen);
950958
this.setState({screenAfterLogin: null});
951959
} else if (localStorage && localStorage.getItem('mx_last_room_id')) {

0 commit comments

Comments
 (0)