如何在jhipster项目中注销后禁用浏览器后退按钮

时间:2017-11-24 11:07:27

标签: angularjs jhipster

我正在使用jhipster Gateway项目。我创建了自定义屏幕,当我尝试注销然后单击浏览器后退按钮时,它导航到之前的屏幕。如何防止这种情况?

我的一个state.js文件:

(function(){     'use strict';

angular
    .module('wheelsoncloudgatewayApp')
    .config(stateConfig);

stateConfig.$inject = ['$stateProvider'];

function stateConfig($stateProvider) {
    $stateProvider.state('tenantRegistration', {
        parent: 'dashboard',
        url: '/tenantRegistration',
        data: {
            authorities: []
        },
        views: {
            'content@': {
                templateUrl: 'app/dashboard/tenantRegistration/tenantRegistration.html',
                controller: 'TenantRegistrationController',
                controllerAs: 'vm'
            }
        }

    });
    $stateProvider.state('tenantView', {
        parent: 'dashboard',
        url: '/tenantDetails',
        data: {
            authorities: []
        },
        views: {
            'content@': {
                templateUrl: 'app/dashboard/tenantRegistration/tenant.html',
                controller: 'TenantRegistrationController',
                controllerAs: 'vm'
            }

        }

    });
    $stateProvider.state('tenantUserView', {
        parent: 'dashboard',
        url: '/userDetails/:id',
        data: {
            authorities: []
        },
        views: {
            'content@': {
                templateUrl: 'app/dashboard/tenantRegistration/userDetail.html',
                controller: 'TenantRegistrationController',
                controllerAs: 'vm'
            }
        }

    });

}

})();

1 个答案:

答案 0 :(得分:1)

通过设置authorities: ['ROLE_USER']来保护您的状态,它会阻止匿名用户(在注销后)达到tenantView状态。请参阅http://www.jhipster.tech/using-angularjs/

上的文档