RafaelVidaurre / angular-permission

Simple route authorization via roles/permissions
MIT License
1.13k stars 212 forks source link

PermPermissionStore has no method define Permission #432

Open iamdeadman opened 7 years ago

iamdeadman commented 7 years ago

Hi,

I had tried angular-permission in one of my previous projects with version 2.3.8 I believe and It was working fine. Now, while setting up a new project with the updated newest version we are getting - 79 Uncaught TypeError: PermPermissionStore.definePermission is not a function

for the setup 1) I used the unminified files from "bower install angular-permission" (angular-permission.js, angular-permission-ui.js) 2) defined 'permission', 'permission.ui' in app modules.

var altairApp = angular.module('altairApp', [
    'ui.router',
    'oc.lazyLoad',
    'ngSanitize',
    'ngRetina',
    'ncy-angular-breadcrumb',
    'ConsoleLogger',
    'ngResource',
    'ngCookies',
    'permission',
    'permission.ui'
]);

Now in the app run block when I am trying to setup dynamic permissions from server like this -

PermPermissionStore.definePermission('anonymous', function ($stateParams) {
        var deferred = $q.defer();
        Auth.isLoggedInAsync(function(cb){
            if (cb && cb == true) deferred.reject();
            else deferred.resolve();
        });
        return deferred.promise;
    });

Where Auth service handles the logic for authenticating / retrieving role info from server. Now, I am getting that definePermissions is not a function.

[Note: I am not including the dependencies (permissions.js / permissions-ui.js) as is in the body / head section of my index.html. But, passing these to my gulp pipeline for minification and concatenation into one single deps file for production, but I read in the issues section somewhere that minified versions might create / have some issues. So, to check this issue I did try to include them in the main index.html after my angular script definition, but got the same error again. ]

What might be the issue here, can anyone help me debug this issue.