Poll for authentication completion

on registration (both for email validation and completion of the
whole auth session).
This commit is contained in:
David Baker 2017-02-24 17:24:10 +00:00
parent 76b381b849
commit 454aa0757a
3 changed files with 17 additions and 0 deletions

View file

@ -57,6 +57,10 @@ export default React.createClass({
sessionId: React.PropTypes.string, sessionId: React.PropTypes.string,
clientSecret: React.PropTypes.string, clientSecret: React.PropTypes.string,
emailSid: 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() { getInitialState: function() {
@ -97,10 +101,21 @@ export default React.createClass({
errorText: msg errorText: msg
}); });
}).done(); }).done();
this._intervalId = null;
if (this.props.poll) {
this._intervalId = setInterval(() => {
this._authLogic.poll();
}, 2000);
}
}, },
componentWillUnmount: function() { componentWillUnmount: function() {
this._unmounted = true; this._unmounted = true;
if (this._intervalId !== null) {
clearInterval(this._intervalId);
}
}, },
_authStateUpdated: function(stageType, stageState) { _authStateUpdated: function(stageType, stageState) {

View file

@ -311,6 +311,7 @@ module.exports = React.createClass({
sessionId={this.props.sessionId} sessionId={this.props.sessionId}
clientSecret={this.props.clientSecret} clientSecret={this.props.clientSecret}
emailSid={this.props.idSid} emailSid={this.props.idSid}
poll={true}
/> />
); );
} else if (this.state.busy || this.state.teamServerBusy) { } else if (this.state.busy || this.state.teamServerBusy) {

View file

@ -184,6 +184,7 @@ export const EmailIdentityAuthEntry = React.createClass({
errorText: React.PropTypes.string, errorText: React.PropTypes.string,
authSessionId: React.PropTypes.string.isRequired, authSessionId: React.PropTypes.string.isRequired,
inputs: React.PropTypes.object.isRequired, inputs: React.PropTypes.object.isRequired,
stageState: React.PropTypes.object.isRequired,
}, },
render: function() { render: function() {