-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue on state authorization #81
Comments
I am also getting the same issue tracked down here: |
This error seems to have emerged out of nowhere, could it be the What version are you guys using |
After further investigation I found this was only an issue when using both ui-router-extras and angular-permission. Seems like both libraries are catching the "stateChangeStart" event. I'm not exactly sure who is at fault here but platdesign made a fix for the ui-router-extras library. After implementing this one line fix the error went away. For those interested see this link.
|
This would not be our problem as we are not using ct-ui-router-extras currently in our project.
|
Not sure if it is correct but according to what was said in that link the core of the problem is with angular-permission. I'll quote here what was said:
...
Might be worth at least looking into. |
Hi, ui-router-extras guy here. Extras has code which keeps track of every I can add some logic in Extras that will work around the problem, but these two features ( Note that in 1.0 we've substantially improved the ui-router integration hooks making things like angular-permission much easier. |
Will have a look at the 1.0 version, The fake state emission is the source
|
@Narzerus 1.0 is close to an alpha release, but hasn't gotten much testing besides our own unit tests. Would love to get some feedback on it. you'll do something like so: // gets permissions config from a state
let getPermissions = (state) => state.permissions || state.data && state.data.permissions
app.run(($transitions) => {
// When a transition starts, and getPermissions returns truthy for
// the "to" state, run the checkPermissionsHook
$transitions.onStart({ to: getPermissions }, checkPermissionsHook);
}
// $transition$ has data about the current transition, including the "to state"
checkPermissionsHook.$inject = ['$transition$', '$state'];
function checkPermissionsHook($transition$, $state) {
let to = $transition$.to();
let permissions = getPermissions(to);
let toParams = $transition$.params();
// do $stateChangePermissionStart eventing here
return Permission.authorize(permissions, toParams)
.then(() => /* do $stateChangePermissionAccepted eventing here */)
.catch((error) => {
// do $stateChangePermissionDenied eventing
if (permissions.redirectTo) {
state = // get redirect to state
var targetState = $state.targetState(state);
// asynchronously returning a redirect from the hook
return $transition$.redirect(targetState);
} else {
return false; // cancels transition
}
});
} Note that since this is pre-alpha, the API may change, especially around returning the redirect. I think the API is pretty close to done though. |
Is there a complete solution for @christopherthielen can you help please with your previous code.
|
@temka1234 the code I wrote is for the currently unreleased |
Any updates on this issue? Would love to use angular-permission and ui-router-extras together. |
Wwe can't solve it till release of ui-router 1.0.0. There will be changes in api that allow us to fix those issues. Sorry. |
Here simple plunker example of angular-permission with ui-router 1.0alpha http://plnkr.co/edit/AuScw1?p=preview. Changes in angular-permission: https://github.com/temka1234/angular-permission/tree/ui-router-1.0 |
Create "ui-router-1.0" branch, fix tests. |
…of browser history and problem with ui-router-extras. Either I am super smart or super dumb. But it works.
#81 Removed triggering $stateChangeSuccess. Solving issue with order …
@temka1234 The code itself looks great, but as long as ui-router guys don't make official release we can not rely on this code. But! But i got idea how to make it work with 0.2.x. I just need to refactor ParmissionMap and release 2.1.0 that will solve the history messing problem. |
:0 awesome! On Sun, Feb 28, 2016, 1:43 PM Błażej Krysiak notifications@github.com
|
Solved in v2.0.1 |
When a state is found to be authorized, the code that allows the state to continue and broadcasts the success message.
However, we are getting an error '$$hashKey' not defined on state change. We traced it back to angular-permission line 49. In the source, you said this is a hacky fix that should be fixed in later versions on UI-router. Could this be the culprit?
The text was updated successfully, but these errors were encountered: