Im using angular-permission library. I defined some of permissions in run():
PermPermissionStore
.definePermission('isAuthorize', function () {
console.log('isAuthorize', OAuth.isAuthenticated());
return OAuth.isAuthenticated();
});
and then im checking users permissions in my routes.js
.state('app.main', {
abstract: true,
template: '<ui-view></ui-view>',
data: {
permissions: {
only: ['isAuthorize'],
redirectTo: {
default: 'login'
}
}
}
})
But i need to ask for profileData first on every refresh of the page, and permission-checking needs to run after i resolve promise. I've try to add resolve on parent State like this, but it still first asking for permisson for app.main and then promise is being resolved.
.state('app', {
abstract: true,
template: '<ui-view></ui-view>',
controller: function ($rootScope, userData) {
$rootScope.roles = userData.user.roles;
},
resolve: {
userData: ["ProfileFactory", function (ProfileFactory) {
return ProfileFactory
.get()
.$promise;
}]
}
})