mirror of https://github.com/vector-im/riot-web
Merge pull request #336 from matrix-org/dbkr/add_email_fail_if_in_use
Use HS proxy API for requestToken on adding emailpull/21833/head
commit
02e2ade7d9
|
@ -38,11 +38,13 @@ class AddThreepid {
|
||||||
*/
|
*/
|
||||||
addEmailAddress(emailAddress, bind) {
|
addEmailAddress(emailAddress, bind) {
|
||||||
this.bind = bind;
|
this.bind = bind;
|
||||||
return MatrixClientPeg.get().requestEmailToken(emailAddress, this.clientSecret, 1).then((res) => {
|
return MatrixClientPeg.get().requestAdd3pidEmailToken(emailAddress, this.clientSecret, 1).then((res) => {
|
||||||
this.sessionId = res.sid;
|
this.sessionId = res.sid;
|
||||||
return res;
|
return res;
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
if (err.httpStatus) {
|
if (err.errcode == 'M_THREEPID_IN_USE') {
|
||||||
|
err.message = "This email address is already in use";
|
||||||
|
} else if (err.httpStatus) {
|
||||||
err.message = err.message + ` (Status ${err.httpStatus})`;
|
err.message = err.message + ` (Status ${err.httpStatus})`;
|
||||||
}
|
}
|
||||||
throw err;
|
throw err;
|
||||||
|
|
|
@ -214,9 +214,10 @@ module.exports = React.createClass({
|
||||||
onFinished: this.onEmailDialogFinished,
|
onFinished: this.onEmailDialogFinished,
|
||||||
});
|
});
|
||||||
}, (err) => {
|
}, (err) => {
|
||||||
|
this.setState({email_add_pending: false});
|
||||||
Modal.createDialog(ErrorDialog, {
|
Modal.createDialog(ErrorDialog, {
|
||||||
title: "Unable to add email address",
|
title: "Unable to add email address",
|
||||||
description: err.toString()
|
description: err.message
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ReactDOM.findDOMNode(this.refs.add_threepid_input).blur();
|
ReactDOM.findDOMNode(this.refs.add_threepid_input).blur();
|
||||||
|
|
Loading…
Reference in New Issue