{"action":"created","issue":{"url":"https://api.github.com/repos/Narzerus/angular-permission/issues/338","repository_url":"https://api.github.com/repos/Narzerus/angular-permission","labels_url":"https://api.github.com/repos/Narzerus/angular-permission/issues/338/labels{/name}","comments_url":"https://api.github.com/repos/Narzerus/angular-permission/issues/338/comments","events_url":"https://api.github.com/repos/Narzerus/angular-permission/issues/338/events","html_url":"https://github.com/Narzerus/angular-permission/issues/338","id":182095666,"number":338,"title":"Permissions evaluating multiple times for child states","user":{"login":"joeljeske","id":5332920,"avatar_url":"https://avatars.githubusercontent.com/u/5332920?v=3","gravatar_id":"","url":"https://api.github.com/users/joeljeske","html_url":"https://github.com/joeljeske","followers_url":"https://api.github.com/users/joeljeske/followers","following_url":"https://api.github.com/users/joeljeske/following{/other_user}","gists_url":"https://api.github.com/users/joeljeske/gists{/gist_id}","starred_url":"https://api.github.com/users/joeljeske/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joeljeske/subscriptions","organizations_url":"https://api.github.com/users/joeljeske/orgs","repos_url":"https://api.github.com/users/joeljeske/repos","events_url":"https://api.github.com/users/joeljeske/events{/privacy}","received_events_url":"https://api.github.com/users/joeljeske/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-10-10T19:28:09Z","updated_at":"2016-10-19T09:59:44Z","closed_at":null,"body":"In usage with UI Router: \r\n\r\n**Issue:**\r\nA given permission is evaluated multiple times if a child state does not override the inherited data.permission property. \r\n\r\n**Use Case:** \r\nCurrently, I have a root 'authenticated' states which does a check to make sure I am logged in. Child states that do not have any other permissions, end up evaluating the parent permission for the parent & the child. This is caused by UI Router's data proto inheritance when it is not overridden. \r\n\r\n```\r\n// State Config\r\n$stateProvider\r\n  .state('root', {\r\n    ...\r\n    data: {\r\n      permissions: {\r\n        only: 'isLoggedIn'\r\n      }\r\n    }\r\n  })\r\n  .state('root.child1', {\r\n    ...\r\n  });\r\n  .state('root.child2', {\r\n    ...\r\n  });\r\n```\r\n\r\nWhen navigating to `root.child`, the `'isLoggedIn' permission is evaluated twice; once for the parent, and once for the child. \r\n\r\n**Culprit Code:**\r\nhttps://github.com/Narzerus/angular-permission/blob/master/src/permission-ui/authorization/StatePermissionMap.js#L23-L30\r\n\r\n\r\n**What I Want**\r\n\r\nI really want 2 things; they could be considered separate issues. \r\n\r\n1. I want to evaluate the permissions for a state inheritance *once*. If a child does not have any other permissions, I do not want to re-evaluate the parent's permissions. \r\n2. If I navigate from `root.child1` -> `root.child2`, I do not want to evaluate the parent's (`root`s) permissions. Similar to how UI-Router's resolve blocks works. It only evaluates the changes necessary to perform the transition. "},"comment":{"url":"https://api.github.com/repos/Narzerus/angular-permission/issues/comments/254768600","html_url":"https://github.com/Narzerus/angular-permission/issues/338#issuecomment-254768600","issue_url":"https://api.github.com/repos/Narzerus/angular-permission/issues/338","id":254768600,"user":{"login":"salacis","id":11746412,"avatar_url":"https://avatars.githubusercontent.com/u/11746412?v=3","gravatar_id":"","url":"https://api.github.com/users/salacis","html_url":"https://github.com/salacis","followers_url":"https://api.github.com/users/salacis/followers","following_url":"https://api.github.com/users/salacis/following{/other_user}","gists_url":"https://api.github.com/users/salacis/gists{/gist_id}","starred_url":"https://api.github.com/users/salacis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/salacis/subscriptions","organizations_url":"https://api.github.com/users/salacis/orgs","repos_url":"https://api.github.com/users/salacis/repos","events_url":"https://api.github.com/users/salacis/events{/privacy}","received_events_url":"https://api.github.com/users/salacis/received_events","type":"User","site_admin":false},"created_at":"2016-10-19T09:59:44Z","updated_at":"2016-10-19T09:59:44Z","body":"The thing you descripe as re-evulation of the parent's root (Goal 2). Is it possible that this would effect the amount of times the permission function would be called? Because in my case if I visit a nested state like \r\n`parent -> child -> child -> child`, the function is called 4 times. Even if I vistig the last state initialy."}}
{"actor":{"display_login":"salacis"}}