Socket
Book a DemoInstallSign in
Socket

angular-symfony-acl

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-symfony-acl

ACL component for Angular Js based on symfony2 user roles

1.0.9
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

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';
    });
  }]);

Keywords

angular

FAQs

Package last updated on 26 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.