Skip to content

Commit

Permalink
Merge pull request #65 from alexweltman/3.2.2_KibanaNoTimeoutOnSearch
Browse files Browse the repository at this point in the history
Kibana Searches update Token Timeout [merge with www PR]
  • Loading branch information
craig-cogdill authored Sep 13, 2016
2 parents 521407f + 6b980b9 commit c94deb7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
25 changes: 15 additions & 10 deletions src/kibana/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,6 @@ define(function (require) {
var jwtPattern = /jwt=(.*?)(&|$)/i;
var jwt = String(hrefUrl).match(jwtPattern);
localStorage.setItem('token', jwt[1]);
RestangularProvider.addResponseInterceptor(function(data, operation, what, url, response, deferred) {
// TODO: standardized error handling - right now we soft fail errors to empty data

// Redirect API login failure response to login page
if (data.status !== 'success' && data.message && data.message.match(/you must be logged in/gi)) {
location.href = '/login.php';
}

return data && data.status === 'success' ? data.data : {error: true, message: data.message};
});
RestangularProvider.addFullRequestInterceptor(function() {
const config = { headers: {} };
const token = localStorage.getItem('token');
Expand All @@ -75,6 +65,21 @@ define(function (require) {
}
return config;
});
RestangularProvider.addResponseInterceptor(function(data, operation, what, url, response, deferred) {
if (data && data.status === 'success') {
if (data.token) {
localStorage.setItem('token', data.token);
}
return data.data;
} else {
return { error: true, message: data.message };
}
});
RestangularProvider.setErrorInterceptor(function(response, deferred, responseHandler) {
if (response.status === 401) {
location.href = '/login';
}
});
})
.config(['ngClipProvider', function (ngClipProvider) {
ngClipProvider.setPath('bower_components/zeroclipboard/dist/ZeroClipboard.swf');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ define(function (require) {
var timeFrom = timeRange.min;
var timeTo = timeRange.max;

if (!timeFrom || !timeTo ||
query === '' ||
query === '*') {
if (!timeFrom || !timeTo) {
return;
}

Expand Down

0 comments on commit c94deb7

Please sign in to comment.