Handle no-auth-flow error from js-sdk

This commit is contained in:
David Baker 2017-03-15 16:44:56 +00:00
parent 2c1ac29d30
commit d292a627d8
2 changed files with 12 additions and 2 deletions

View File

@ -107,7 +107,6 @@ export default React.createClass({
return;
}
const msg = error.message || error.toString();
this.setState({
errorText: msg
});

View File

@ -155,10 +155,21 @@ module.exports = React.createClass({
_onUIAuthFinished: function(success, response, extra) {
if (!success) {
let msg = response.message || response.toString();
// can we give a better error message?
if (response.required_stages && response.required_stages.indexOf('m.login.msisdn') > -1) {
let msisdn_available = false;
for (const flow of response.available_flows) {
msisdn_available |= flow.stages.indexOf('m.login.msisdn') > -1;
}
if (!msisdn_available) {
msg = "This server does not support authentication with a phone number";
}
}
this.setState({
busy: false,
doingUIAuth: false,
errorText: response.message || response.toString(),
errorText: msg,
});
return;
}