angular-app/angular-app — pull request #119 by petebacondarwin (2013-03-08 21:50:45+00:00)
Title: refact(security): Complete refactoring of the security services

Big re-organization of the code.

Now there is one main service that app developers should use: security. This contains all the methods for getting info about the current user and logging in and out.

There is a new provider called securityAuthorizationProvider, that can be used in route definitions to create resolves that check authorization. See `admin-project.js` or `admin-users.js` config block for example of how to use this.

I decided that it was bad to put services straight onto templates generally, as it is hard to test this. Therefore things like login-toolbar now, instead of say attaching security service to the scope and then have `security.showLogin()` in the template, we attach security.showLogin function to scope.login and call that in the template. Equally, instead of referring to security.currentUser in the template, now we watch security.currentUser and copy it into scope.currentUser when it changes.