Skip to content

Commit

Permalink
Fixed access denied page (elastic#68046) (elastic#68343)
Browse files Browse the repository at this point in the history
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
igoristic and elasticmachine authored Jun 5, 2020
1 parent b035dd9 commit 7ce16b8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
13 changes: 7 additions & 6 deletions x-pack/plugins/monitoring/public/views/access_denied/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@

<div class="kuiInfoPanelBody__message">
<div class="kuiButtonGroup">
<button
ng-click="accessDenied.goToKibana();"
class="kuiButton kuiButton--primary"
i18n-id="xpack.monitoring.accessDenied.backToKibanaButtonLabel"
i18n-default-message="Back to Kibana"
></button>
<a ng-href="{{ accessDenied.goToKibanaURL }}">
<button
class="kuiButton kuiButton--primary"
i18n-id="xpack.monitoring.accessDenied.backToKibanaButtonLabel"
i18n-default-message="Back to Kibana"
></button>
</a>
</div>
</div>
</div>
Expand Down
13 changes: 4 additions & 9 deletions x-pack/plugins/monitoring/public/views/access_denied/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { noop } from 'lodash';
import { kbnBaseUrl } from '../../../../../../src/plugins/kibana_legacy/common/kbn_base_url';
import { uiRoutes } from '../../angular/helpers/routes';
import { Legacy } from '../../legacy_shims';
import template from './index.html';

const tryPrivilege = ($http, kbnUrl) => {
return $http
.get('../api/monitoring/v1/check_access')
.then(() => kbnUrl.redirect('/home'))
.catch(noop);
.catch(() => true);
};

uiRoutes.when('/access-denied', {
Expand All @@ -31,17 +30,13 @@ uiRoutes.when('/access-denied', {
},
},
controllerAs: 'accessDenied',
controller($scope, $injector) {
const $window = $injector.get('$window');
const kbnBaseUrl = $injector.get('kbnBaseUrl');
controller: function ($scope, $injector) {
const $http = $injector.get('$http');
const kbnUrl = $injector.get('kbnUrl');
const $interval = $injector.get('$interval');

// The template's "Back to Kibana" button click handler
this.goToKibana = () => {
$window.location.href = Legacy.shims.getBasePath() + kbnBaseUrl;
};
this.goToKibanaURL = kbnBaseUrl;

// keep trying to load data in the background
const accessPoller = $interval(() => tryPrivilege($http, kbnUrl), 5 * 1000); // every 5 seconds
Expand Down

0 comments on commit 7ce16b8

Please sign in to comment.