Amsaveni Natarajan
Amsaveni Natarajan

Reputation: 133

How to disable browser back button after logout in jhipster project

I am using a jhipster Gateway project. I have created custom screens and when i tried to logout and then clicked the browser back button, its navigating to the previous screens. How to prevent this ?

One of my state.js file:

(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'
            }
        }

    });

}

})();

Upvotes: 1

Views: 579

Answers (1)

Gaël Marziou
Gaël Marziou

Reputation: 16294

Protect your states by setting authorities: ['ROLE_USER'] it will prevent anonymous user (after logout) to reach tenantView state. See doc at http://www.jhipster.tech/using-angularjs/

Upvotes: 1

Related Questions