PHPackages                             nrayann/my-acl - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. nrayann/my-acl

ActiveCakephp-plugin[Authentication &amp; Authorization](/categories/authentication)

nrayann/my-acl
==============

CakePHP plugin for manage ACL with a friendly interface.

1.0.0-alpha(9y ago)134MITPHPPHP &gt;=5.4.16

Since Sep 12Pushed 9y ago2 watchersCompare

[ Source](https://github.com/nrayann/my-acl)[ Packagist](https://packagist.org/packages/nrayann/my-acl)[ Docs](https://github.com/nrayann)[ RSS](/packages/nrayann-my-acl/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (3)Versions (3)Used By (0)

MyAcl plugin for CakePHP
========================

[](#myacl-plugin-for-cakephp)

[![Latest Stable Version](https://camo.githubusercontent.com/6c25d4609c2bb63305990935eabc734f35b06eaf5f6e9ea991102541311320cd/68747470733a2f2f706f7365722e707567782e6f72672f6e726179616e6e2f6d792d61636c2f762f737461626c65)](https://packagist.org/packages/nrayann/my-acl)[![Total Downloads](https://camo.githubusercontent.com/8e0224807a5adea80e79445f231ab97e9f7bca5fddedf526b1da349e1f64a918/68747470733a2f2f706f7365722e707567782e6f72672f6e726179616e6e2f6d792d61636c2f646f776e6c6f616473)](https://packagist.org/packages/nrayann/my-acl)[![License](https://camo.githubusercontent.com/ec3617dac2c1eceaffbd840f02c336b4d08abc42a27d3988a6814b435f2e8296/68747470733a2f2f706f7365722e707567782e6f72672f6e726179616e6e2f6d792d61636c2f6c6963656e7365)](https://packagist.org/packages/nrayann/my-acl)[![composer.lock](https://camo.githubusercontent.com/b2e1e3f3afb0f0d41728dda03fd909612281cdfb8427850c48932db69fc04b51/68747470733a2f2f706f7365722e707567782e6f72672f6e726179616e6e2f6d792d61636c2f636f6d706f7365726c6f636b)](https://packagist.org/packages/nrayann/my-acl)

Installation
------------

[](#installation)

You can install this plugin into your CakePHP application using [composer](http://getcomposer.org).

The recommended way to install composer packages is:

```
composer require 'nrayann/my-acl:dev-master'

```

Include the ACL and MyAcl plugin in app/config/bootstrap.php

```
Plugin::load('Acl', ['bootstrap' => true]);
Plugin::load('MyAcl', ['bootstrap' => false, 'routes' => true]);
```

Include and configure the AuthComponent and the AclComponent in the AppController

```
public $components = [
    'Acl' => [
        'className' => 'Acl.Acl'
    ]
];
...
$this->loadComponent('Auth', [
    'authorize' => [
        'Acl.Actions' => ['actionPath' => 'controllers/']
    ],
    'loginAction' => [
        'plugin' => false,
        'controller' => 'Users',
        'action' => 'login'
    ],
    'loginRedirect' => [
        'plugin' => false,
        'controller' => 'Pages',
        'action' => 'display'
    ],
    'logoutRedirect' => [
        'plugin' => false,
        'controller' => 'Users',
        'action' => 'login'
    ],
    'unauthorizedRedirect' => [
        'plugin' => false,
        'controller' => 'Users',
        'action' => 'login',
        'prefix' => false
    ],
    'authError' => 'You are not authorized to access that location.',
    'flash' => [
        'element' => 'error'
    ]
]);
```

Add UsersController::login function

```
public function login() {
    if ($this->request->is('post')) {
        $user = $this->Auth->identify();
        if ($user) {
            $this->Auth->setUser($user);
            return $this->redirect($this->Auth->redirectUrl());
        }
        $this->Flash->error(__('Your username or password was incorrect.'));
    }
}
```

Add UsersController::logout function

```
public function logout() {
    $this->Flash->success(__('Good-Bye'));
    $this->redirect($this->Auth->logout());
}
```

Add src/Templates/Users/login.ctp

```
