From 977b8a7379c169cc817322e21d8f7613b7609217 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 3 Mar 2017 12:08:26 +0000 Subject: [PATCH] Make UIAuth Dialog show an error when auth fails --- src/components/structures/InteractiveAuth.js | 11 ++-- .../structures/login/Registration.js | 2 +- .../views/dialogs/InteractiveAuthDialog.js | 51 ++++++++++++++++--- 3 files changed, 52 insertions(+), 12 deletions(-) diff --git a/src/components/structures/InteractiveAuth.js b/src/components/structures/InteractiveAuth.js index 7337ec730c..4f050cc246 100644 --- a/src/components/structures/InteractiveAuth.js +++ b/src/components/structures/InteractiveAuth.js @@ -41,11 +41,12 @@ export default React.createClass({ // callback makeRequest: React.PropTypes.func.isRequired, - // callback called when the auth process has finished + // callback called when the auth process has finished, + // successfully or unsuccessfully. // @param {bool} status True if the operation requiring // auth was completed sucessfully, false if canceled. // @param result The result of the authenticated call - onFinished: React.PropTypes.func.isRequired, + onAuthFinished: React.PropTypes.func.isRequired, // Inputs provided by the user to the auth process // and used by various stages. As passed to js-sdk @@ -87,9 +88,9 @@ export default React.createClass({ }); this._authLogic.attemptAuth().then((result) => { - this.props.onFinished(true, result); + this.props.onAuthFinished(true, result); }).catch((error) => { - this.props.onFinished(false, error); + this.props.onAuthFinished(false, error); console.error("Error during user-interactive auth:", error); if (this._unmounted) { return; @@ -179,7 +180,7 @@ export default React.createClass({ }, _onAuthStageFailed: function(e) { - this.props.onFinished(false, e); + this.props.onAuthFinished(false, e); }, _setEmailSid: function(sid) { this._authLogic.setEmailSid(sid); diff --git a/src/components/structures/login/Registration.js b/src/components/structures/login/Registration.js index 2c68b140e3..c25d74f566 100644 --- a/src/components/structures/login/Registration.js +++ b/src/components/structures/login/Registration.js @@ -338,7 +338,7 @@ module.exports = React.createClass({ + let content; + if (this.state.authError) { + content = ( +
+
{this.state.authError.message || this.state.authError.toString()}
+
+ + Dismiss + +
+ ); + } else { + content = (
+ ); + } + + return ( + + {content} ); },