Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.8] Fixed access denied page (#68046) #68343

Merged
merged 1 commit into from
Jun 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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