RafaelVidaurre / angular-permission

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

Problem with async permRoleStore #353

Closed muuvmuuv closed 7 years ago

muuvmuuv commented 7 years ago

Hey I literally read the issues how to fix this but I did not help at my point. I've a AdminService that pulls all roles from a database and check some things within a function. That all will stored in an object and after pushed into the .defineManyRoles function. After that I sync and listen the $urlRouter. I added $urlRouterProvider.deferIntercept(); to my config, but it still wont work.

Here is the full app.js: http://hastebin.com/sesezuhana.php

Info:

masterspambot commented 7 years ago

Have you seen this? https://github.com/Narzerus/angular-permission/wiki/Controlling-access-in-views#async-calls-for-permissions-in-initial-states I think that is the solution you are looking for.

muuvmuuv commented 7 years ago

@masterspambot yep I followed these introductions (I read the wiki before..). I think the problem in my point is that I call an API to handle HTTP request (Code above). Just for short: AdminService.GetUserRoles().then(function (userRoles) { - calls the userRoles as: 1,2,3,4 a map function creates an array for your defineManyRoles function and a loop creates the object to call this function. First I thought its my loop that is creating an error. So I declared a single user role within my Service, but with no successful result.

masterspambot commented 7 years ago

So this is the problem of mapping the response not the lib itself right?

muuvmuuv commented 7 years ago

@masterspambot I think so, yeah. Could you help me out ? I tried asking in some forums, but with no response.

masterspambot commented 7 years ago

No problem. Write to me on gitter (https://gitter.im) ok?

I am closing this issue and let's solve it together.