adding verification view

This commit is contained in:
or-else
2018-03-14 20:22:04 -07:00
parent 6d8b49c36c
commit 57490cbe92
+40 -12
View File
@@ -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' ?
<div><input type="text" /> [confirm]</div> :
null}
</div>
);
@@ -3460,7 +3469,8 @@
contextMenuItems: [],
serverVersion: 'no connection',
contactsSearchQuery: '',
foundContacts: []
foundContacts: [],
validation: []
};
},
componentDidMount: function() {
@@ -3546,8 +3556,13 @@
}
if (promise) {
promise.then(function() {
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() {
{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");
});