Make email auth component fail better if server claims email isn't validated

https://github.com/matrix-org/synapse/issues/7512 means that (at least)
sometimes after clicking on the email validation link and being redirected
to riot, the server will claim the email identity auth stage is still incomplete.

This meant that we displayed the email identity UIA component but with an empty
email address, because we don't know that in the new session. Work around this by
assuming that if the email UIA component is being displayed but we don't have an
email address input, the link has been clicked and we're just waiting for the poll.

Also don't fire off an initial register request if we're already mid-UI-auth, because
that's confusing and unnecessary.

Also also remove unused requestingToken state.

Fixes https://github.com/vector-im/riot-web/issues/13434
This commit is contained in:
David Baker 2020-05-15 13:32:12 +01:00
parent 47ff67c6be
commit 523067e5f9
2 changed files with 16 additions and 11 deletions

View file

@ -243,10 +243,15 @@ export default createReactClass({
});
};
try {
await this._makeRegisterRequest({});
// This should never succeed since we specified an empty
// auth object.
console.log("Expecting 401 from register request but got success!");
// We do the first registration request ourselves to discover whether we need to
// do SSO instead. If we've already started the UI Auth process though, we don't
// need to.
if (!this.state.doingUIAuth) {
await this._makeRegisterRequest({});
// This should never succeed since we specified an empty
// auth object.
console.log("Expecting 401 from register request but got success!");
}
} catch (e) {
if (e.httpStatus === 401) {
this.setState({

View file

@ -412,14 +412,14 @@ export const EmailIdentityAuthEntry = createReactClass({
this.props.onPhaseChange(DEFAULT_PHASE);
},
getInitialState: function() {
return {
requestingToken: false,
};
},
render: function() {
if (this.state.requestingToken) {
// This component is now only displayed once the token has been requested,
// so we know the email has been sent. It can also get loaded after the user
// has clicked the validation link if the server takes a while to propagate
// the validation internally. If we're in the session spawned from clicking
// the validation link, we won't know the email address, so if we don't have it,
// assume that the link has been clicked and the server will realise when we poll.
if (this.props.inputs.emailAddress === undefined) {
const Loader = sdk.getComponent("elements.Spinner");
return <Loader />;
} else {