0

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?

Phil
  • 157,677
  • 23
  • 242
  • 245
  • I'm not entirely sure how injection works for the `defineRole` callback but should the argument be `$stateParams` (note the dollar-sign prefix)? – Phil Jul 06 '17 at 01:00
  • Tnx for noticing. Yes it should, but it doesn't change anything. – Andrea Andy Jul 06 '17 at 01:08
  • Have you included the `permission.ui` module as a dependency? See https://github.com/Narzerus/angular-permission/wiki/Installation-guide-for-ui-router#including-dependencies-in-module – Phil Jul 06 '17 at 01:12
  • @Phil That's it. Thank you a lot. – Andrea Andy Jul 06 '17 at 07:31

0 Answers0