Closed NitsanBaleli closed 5 years ago
$rootScope.$on('$stateChangePermissionDenied', function(event, toState, toParams, options) { ... });
https://github.com/RafaelVidaurre/angular-permission/wiki/Emitted-events-in-ui-router
@Semkoo AFAIK these events aren't being broadcast when you use uirouter1.x
, that's the issue Im facing
Honestly, I was running into a few bugs and I decided to follow this guide and now I am happy with it
http://adamalbrecht.com/2014/09/22/authorization-with-angular-and-ui-router/
Then when you are comparing the permissions
https://stackoverflow.com/questions/16312528/check-if-an-array-contains-any-element-of-another-array-in-javascript
var findOne = function (haystack, arr) { return arr.some(function (v) { return haystack.indexOf(v) >= 0; }); };
Use any CoffeeScript online compiler to convert into ES2015 to understand it better, happy coding
Any updated on this please?
I currently have no way of knowing if a $transitions.onError
was caused by angular-permission
.
Thanks again
just to better explain the situation, there's no notification before this library redirects to the redirect.state
in line 85 of angular-permission-ui.js
My bad, Im closing this issue, lib works as advertised ;)
$transitions.onError({ to: 'app.**' }, ($transition$: Transition) => {
const nextState = {
state: $transition$.$to().name,
params: $transition$.params('to')
};
window.sessionStorage.setItem(DENIED_ROUTE_SESSION_STORAGE_KEY, JSON.stringify(nextState));
});
Looking at the source code it seems no event is fired like in the older version.
Errors are catched inside the
$transitions.onError
function, but is there anyway to know that a permission was rejected ?Thank you for your work ;)