1.0.9 • Published 9 years ago

angular-symfony-acl v1.0.9

Weekly downloads
39
License
-
Repository
github
Last release
9 years ago

angular-symfony-acl

ACL component for Angular Js based on symfony2 user roles

For usage and examples go to app directory

Installation

Install with bower:

$ bower install angular-symfony-acl --save

Install with npm:

$ npm install angular-symfony-acl

Load the symfony-acl module in your app.

angular.module('app', ['vSymfonyACL']);

Configure

    angular
        .module('app')
        .config(['AccessServiceProvider', config])
    ;
        
    function config(AccessServiceProvider) {
        var myConfig = {
            rolesHierarchy: {
                1: 'ROLE_USER',
                2: 'ROLE_MODERATOR',
                6: 'ROLE_ADMIN',
                7: 'ROLE_SUPER_ADMIN'
            },
            storage: 'localStorage',
            storageKey: 'user'
        };
        AccessServiceProvider.config(myConfig);
    }

Usage Example

Example usage using states:

(function () {
    'use strict';

    angular
        .module('state-provider')
        .config(['$stateProvider', config]);

    function config($stateProvider) {
        $stateProvider
            .state('home', {
                url: "/",
                requireLogin: false,
                views: {
                    "content": {
                        templateUrl: "/src/views/home.view.html",
                        controller: 'HomeController',
                        controllerAs: 'vm'
                    }
                }
            })
            .state('secured', {
                url: "/secured",
                requireLogin: true,
                views: {
                    "content": {
                        templateUrl: "/src/views/secured.view.html",
                        controller: 'SecuredController',
                        controllerAs: 'vm'
                    }
                }
            })
            .state('admin', {
                url: "/admin",
                requireLogin: true,
                roles: ['ROLE_ADMIN', 'ROLE_SUPER_ADMIN'],
                views: {
                    "content": {
                        templateUrl: "/src/views/admin.view.html",
                        controller: 'AdminController',
                        controllerAs: 'vm'
                    }
                }
            })
            .state('superadmin', {
                url: "/super-admin",
                requireLogin: true,
                roles: 'ROLE_SUPER_ADMIN',
                views: {
                    "content": {
                        templateUrl: "/src/views/superadmin.view.html",
                        controller: 'SuperAdminController',
                        controllerAs: 'vm'
                    }
                }
            })

    }

})();

Catch access errors

angular.module('myApp', ['vSymfonyACL'])
  .run(['$rootScope', '$window', function($rootScope, $window) {
    $rootScope.$on('vsymfonyacl:error', function(event, user) {
      return $window.location.href = '/login';
    });
  }]);
1.0.9

9 years ago

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

2.0.0

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

1.0.0

10 years ago