mirror of https://github.com/vector-im/riot-web
Handle errors with scalar-oauthing
Handle error getting the scalar token and check for non-success status codes in the response handler (because apparently browser-request doesn't consider that an error).pull/21833/head
parent
fdcebe1e56
commit
15dccd9871
|
@ -32,6 +32,8 @@ class ScalarAuthClient {
|
||||||
}, (err, response, body) => {
|
}, (err, response, body) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
defer.reject(err);
|
defer.reject(err);
|
||||||
|
} else if (response.statusCode / 100 !== 2) {
|
||||||
|
defer.reject({statusCode: response.statusCode});
|
||||||
} else {
|
} else {
|
||||||
defer.resolve(body.access_token);
|
defer.resolve(body.access_token);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,8 @@ module.exports = React.createClass({
|
||||||
tags: tags,
|
tags: tags,
|
||||||
areNotifsMuted: areNotifsMuted,
|
areNotifsMuted: areNotifsMuted,
|
||||||
isRoomPublished: this._originalIsRoomPublished, // loaded async in componentWillMount
|
isRoomPublished: this._originalIsRoomPublished, // loaded async in componentWillMount
|
||||||
|
scalar_token: null,
|
||||||
|
scalar_error: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -75,6 +77,8 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
this.getScalarToken().done((token) => {
|
this.getScalarToken().done((token) => {
|
||||||
this.setState({scalar_token: token});
|
this.setState({scalar_token: token});
|
||||||
|
}, (err) => {
|
||||||
|
this.setState({scalar_error: err});
|
||||||
});
|
});
|
||||||
|
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
|
@ -578,6 +582,10 @@ module.exports = React.createClass({
|
||||||
<a href="#" onClick={ this.onManageIntegrations }>Manage integrations</a>
|
<a href="#" onClick={ this.onManageIntegrations }>Manage integrations</a>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
} else if (this.state.scalar_error) {
|
||||||
|
integrations_section = <div className="error">
|
||||||
|
Unable to contact integrations server
|
||||||
|
</div>;
|
||||||
} else {
|
} else {
|
||||||
integrations_section = <Loader />;
|
integrations_section = <Loader />;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue