RafaelVidaurre / angular-permission

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

UI-Router 1.x #440

Closed RudmanMario closed 7 years ago

RudmanMario commented 7 years ago

After upgrading to angular-ui-router 1.x it seems that angular-permission is no longer working properly. I'm also using polyfill that re-enables the $stateChangeStart angular events but I still have problems when I'm using $transitions and redirectTo is not working anymore. Is there any chance of migrating to angular-ui-router 1.x?

valentina91p commented 7 years ago

I also have this same problem!

masterspambot commented 7 years ago

What version of ui-router are you using guys? Tests are passing, so it's kinda strange as migration was performed quite time ago.

On Wed, Nov 15, 2017, 14:38 Valentina M. notifications@github.com wrote:

I also have this same problem!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Narzerus/angular-permission/issues/440#issuecomment-344594590, or mute the thread https://github.com/notifications/unsubscribe-auth/AAjeAerpA8lizYQVSUzXb66lNKT1BnB8ks5s2uligaJpZM4QWn3o .

valentina91p commented 7 years ago

It works now for me :), in my case I was working with version 5.1 of angular-permission, and I upgraded it to the latest version, there was no need to include the polyfill to re-enable the $stateChangeStart event.

RudmanMario commented 7 years ago

If it is working for @valentina91p I guess it will work for me too then. I will check it today, but you can close the issue then. Thank you.

Edit: This was creating a problem for me.

$transitions.onStart({to: function(state) {
            return state.name !== 'login';
        }}, function (trans) {
            if(($window.sessionStorage.userToken == 'undefined' || !$window.sessionStorage.userToken)) {
                $state.go('login');
                return false;
            } else {
                return true;
            }
        });

This was preventing my state permissions from executing. When I change it to the $transitions.onEnter the problem was gone so my guess is that it had something to do with transition lifecycle.