From 454aa0757a5d741c5f578c037be8308f479cd209 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 24 Feb 2017 17:24:10 +0000 Subject: [PATCH] Poll for authentication completion on registration (both for email validation and completion of the whole auth session). --- src/components/structures/InteractiveAuth.js | 15 +++++++++++++++ src/components/structures/login/Registration.js | 1 + .../views/login/InteractiveAuthEntryComponents.js | 1 + 3 files changed, 17 insertions(+) diff --git a/src/components/structures/InteractiveAuth.js b/src/components/structures/InteractiveAuth.js index a8b4bc7e9f..2a5d0e022c 100644 --- a/src/components/structures/InteractiveAuth.js +++ b/src/components/structures/InteractiveAuth.js @@ -57,6 +57,10 @@ export default React.createClass({ sessionId: React.PropTypes.string, clientSecret: React.PropTypes.string, emailSid: React.PropTypes.string, + + // If true, poll to see if the auth flow has been completed + // out-of-band + poll: React.PropTypes.bool, }, getInitialState: function() { @@ -97,10 +101,21 @@ export default React.createClass({ errorText: msg }); }).done(); + + this._intervalId = null; + if (this.props.poll) { + this._intervalId = setInterval(() => { + this._authLogic.poll(); + }, 2000); + } }, componentWillUnmount: function() { this._unmounted = true; + + if (this._intervalId !== null) { + clearInterval(this._intervalId); + } }, _authStateUpdated: function(stageType, stageState) { diff --git a/src/components/structures/login/Registration.js b/src/components/structures/login/Registration.js index 5e6946e204..cd4ac1d538 100644 --- a/src/components/structures/login/Registration.js +++ b/src/components/structures/login/Registration.js @@ -311,6 +311,7 @@ module.exports = React.createClass({ sessionId={this.props.sessionId} clientSecret={this.props.clientSecret} emailSid={this.props.idSid} + poll={true} /> ); } else if (this.state.busy || this.state.teamServerBusy) { diff --git a/src/components/views/login/InteractiveAuthEntryComponents.js b/src/components/views/login/InteractiveAuthEntryComponents.js index 9ff3060f89..5bcb94a097 100644 --- a/src/components/views/login/InteractiveAuthEntryComponents.js +++ b/src/components/views/login/InteractiveAuthEntryComponents.js @@ -184,6 +184,7 @@ export const EmailIdentityAuthEntry = React.createClass({ errorText: React.PropTypes.string, authSessionId: React.PropTypes.string.isRequired, inputs: React.PropTypes.object.isRequired, + stageState: React.PropTypes.object.isRequired, }, render: function() {