From 57490cbe92544c09cc8385d55e849f2c24efd5e8 Mon Sep 17 00:00:00 2001 From: or-else Date: Wed, 14 Mar 2018 20:22:04 -0700 Subject: [PATCH] adding verification view --- index.html | 56 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/index.html b/index.html index a3441d8c..c07ce2be 100644 --- a/index.html +++ b/index.html @@ -1078,8 +1078,7 @@ this.state.login.trim(), this.state.password.trim(), vcard(this.state.fn, this.state.imageDataUrl), - null, - to_tags({"email": this.state.email})); + {"type": "email", "val": this.state.email}); } }, render: function() { @@ -1266,13 +1265,17 @@ var avatar = false; switch (this.props.state) { case 'login': - title = "Sign In"; break; + title = "Sign In"; + break; case 'register': - title = "Create Account"; break; + title = "Create Account"; + break; case 'settings': - title = "Settings"; break; + title = "Settings"; + break; case 'edit-account': - title = "Edit Account"; break; + title = "Edit Account"; + break; case 'contacts': title = this.props.title; avatar = this.props.avatar ? this.props.avatar : true; @@ -1280,6 +1283,9 @@ case 'new-topic': title = "Start New Chat"; break; + case 'validation': + title = "Confirm Credentials"; + break; default:; }; return ( @@ -1339,6 +1345,9 @@ onCreateTopic={this.props.onCreateTopic} onError={this.props.onError} /> : + this.props.state === 'validation' ? +
[confirm]
: + null} ); @@ -3460,7 +3469,8 @@ contextMenuItems: [], serverVersion: 'no connection', contactsSearchQuery: '', - foundContacts: [] + foundContacts: [], + validation: [] }; }, componentDidMount: function() { @@ -3546,8 +3556,13 @@ } if (promise) { - promise.then(function() { - instance.handleLoginSuccessful(instance); + promise.then(function(ctrl) { + console.log(ctrl); + if (ctrl.code >= 300 && ctrl.text === "validate credentials") { + instance.handleCredentialsRequest(ctrl.params); + } else { + instance.handleLoginSuccessful(instance); + } }).catch(function(err) { // Login failed, report error instance.setState({loginDisabled: false}); @@ -3556,6 +3571,13 @@ } }, + handleCredentialsRequest: function(params) { + this.setState({ + sidePanelSelected: 'validation', + validation: params.cred + }); + }, + handleLoginSuccessful: function(instance) { instance.handleError("", null); @@ -3707,15 +3729,21 @@ this.setState({sidePanelSelected: 'register'}); }, // Actual registration of a new account. - handleNewAccountRequest: function(login_, password_, public_, private_, tags_) { + handleNewAccountRequest: function(login_, password_, public_, cred_, tags_) { var instance = this; - tags_ = tags_ || []; // init tags_ value just in case undefined Tinode.connect(this.state.serverAddress) .then(function() { + if (cred_ && !Array.isArray(cred_)) { + cred_ = [cred_]; + } return Tinode.createAccountBasic(login_, password_, - {public: public_, private: private_, tags: tags_}); - }).then(function() { - instance.handleLoginSuccessful(instance); + {public: public_, cred: cred_, tags: tags_}); + }).then(function(ctrl) { + if (ctrl.code >= 300 && ctrl.text === "validate credentials") { + instance.handleCredentialsRequest(ctrl.params); + } else { + instance.handleLoginSuccessful(instance); + } }).catch(function(err) { instance.handleError(err.message, "err"); });