fnakstad / angular-client-side-auth

One way to implement authentication/authorization in Angular applications
http://angular-client-side-auth.herokuapp.com/
MIT License
1.63k stars 346 forks source link

Some Bugs I found #37

Closed zbindenren closed 11 years ago

zbindenren commented 11 years ago

In https://github.com/fnakstad/angular-client-side-auth/blob/master/client/js/controllers.js:

You reference $rootScope but you do not inject it.

Secondly you directive just works in Navigation Controller, because userRoles and accessLevels are only defined in the scope of the Navication Controller.

I solved both issues by injecting rootScope and assigning userRoles and accessLevels there.

Maybe it would be a good idea ad the user to the rootScope.

BR, Rene

fnakstad commented 11 years ago

Thanks for letting me know Rene :) Added the missing reference in fdc280f8a198c24b91fcac36fcc73fcd80b33d54. The reason I don't have the user object as a reference in the $rootScope is that it's a bad practice to use $rootScope as a sort of container for "global" data. The recommended approach is to use an Angular service to share data between controllers instead. So, if you want access to the userRoles and accessLevels in other controllers you can inject the Auth controller and get the userRoles and accessLevels from it instead.

zbindenren commented 10 years ago

Thanks for the info.