Angular Authorization layer
This module allows you to add authorization layer to your angular project, and to filter pages for "anonymous" and "authenticated" users.
Installation
** You can assist the example on AuthExample.js
of using ngAuth
with ng-facebook
module **
- Download using one of the following options:
- npm:
npm install ngauth
- bower:
bower install ngAuth
- git
- npm:
- Add the module to your dependencies and include its scripts
- Create your own authentication service by implementing the
AuthBase
abstract:*** useangular;AuthBase
dependency for regularng-route
, andAuthBaseUI
forrouter-ui
*** - Implement the following methods:
2.1.
setIsLoggedIn()
should check if the user is logged-in:true
- logged-in userfalse
- anonymous usernull
- information not available yet(waiting to response)
Usage
Defining routes
- add
anonymous: true
to every route which allowed only for anonymous users - add
authenticated: true
to every route which allowed only for anonymous users
Example:
$stateProvider ;
Authentication status change handler
You can attach handler for every time the authentication status is changed and ready, by listening to Auth.status
:
Example:
$rootScope;
Add login/logout methods to your auth service
It's recommended to add your login/logout method on your auth service.