handled 401 errors when credentials are not provided
This commit is contained in:
parent
ba956bc045
commit
93f09508ac
2 changed files with 6 additions and 6 deletions
|
|
@ -258,8 +258,8 @@ class ArveData(BaseRequestHandler):
|
|||
|
||||
if (client_id == '<undefined>' or client_secret == '<undefined>' or arve_api_key == '<undefined>'):
|
||||
# If the credentials are not defined, we skip the ARVE API connection
|
||||
return self.finish('ARVE API credentials not defined.')
|
||||
|
||||
return self.send_error(401)
|
||||
|
||||
http_client = AsyncHTTPClient()
|
||||
|
||||
URL = 'https://arveapi.auth.eu-central-1.amazoncognito.com/oauth2/token'
|
||||
|
|
|
|||
|
|
@ -312,7 +312,6 @@ function show_sensors_data(url) {
|
|||
url: `${$('#url_prefix').data().calculator_prefix}/api/arve/v1/${HOTEL_ID}/${FLOOR_ID}`,
|
||||
type: 'GET',
|
||||
success: function (result) {
|
||||
if (result.length == 0) return; // If the ARVE credentials were not defined, we don't have a valid result.
|
||||
DATA_FROM_SENSORS = result;
|
||||
result.map(room => {
|
||||
if (room['Details']['Online'] == false) return; // If the sensor is offline, it should not be added to the list.
|
||||
|
|
@ -332,9 +331,10 @@ function show_sensors_data(url) {
|
|||
}));
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
alert('Authentication Error - Something went wrong during the authentication process.');
|
||||
},
|
||||
error: function(_, _, errorThrown) {
|
||||
if (errorThrown != 'Unauthorized') alert(errorThrown);
|
||||
else alert('Unauthorized - Something went wrong during the ARVE API authentication process.');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue