Angular-permission roles doesn't redirect if role condition is false

297 Views Asked by At

I'm using angular-permission 5.3.2. Here is my app.run.js

(function() {
'use strict';

angular
    .module('myApp')
    .run(run);
/** @ngInject */
function run(PermRoleStore, PermPermissionStore, $auth)
{
    PermRoleStore
        .defineRole('user', function (stateParams) {
            if($auth.isAuthenticated()) {
                return true; // Is loggedin
            }
            return false;
        });
}})();

And here is how I check for permission for route view2

     .state('view2', {
            url: '/view2',
            templateUrl: 'view2/view2.html',
            controller: 'View2Ctrl as vm',
            data: {
                permissions: {
                    only: 'user',
                    redirectTo: 'view1'
                }
            },


        });

The problem is that I'm not redirected to view1, even if I'm not logged in. Does anyone know where's the problem?

0

There are 0 best solutions below