ppiixx/cake-authorizer

该包已被废弃,不再维护。没有建议的替代包。

为 CakePHP v3.0 优秀的授权器

安装: 113

依赖: 0

建议者: 0

安全: 0

星星: 1

关注者: 2

公开问题: 0

类型:cakephp-plugin

1.0.3 2015-07-21 17:34 UTC

This package is not auto-updated.

Last update: 2015-11-29 05:23:00 UTC


README

简介

我们开发的第一个插件,用于通过工具和组之间的关系帮助用户进行授权

安装

需要此包

composer require ppiixx/authorizer

运行以下命令

bin/cake plugin load -r
bin/cake migrations migrate -p
bin/cake seed_cake_authorizer

Auth 配置示例

// AppController.php
public function initialize()
{
  .
  .
  .
  $this->loadComponent('Auth', [
      'authorize'   => ['.Cake'],
      'loginAction' => [
          'controller' => 'Users',
          'action'     => 'login',
          'plugin'     => ''
      ],
      'loginRedirect' => [
          'controller'    => 'Users',
          'action'    => 'index',
          'plugin'     => ''
      ]   
  ]);
}

别忘了在 app.php 中配置电子邮件

组件

加载 Authorizer 组件以返回所有用户的工具

$this->loadComponent('.Authorizer');

// Sample of use
$tools = $this->Authorizer->userTools($this->Auth->user('id'));

自定义配置

如果您想自定义默认配置,请将此方法添加到您的 AppController.php 中

protected function customConfig()
{
  //  $controller = $this->request->param('controller') . '/' . $this->request->param('action');

  //  if($controller == 'Users/login' || $controller == 'Users/forgot' || $controller == 'Users/recover')
  //      $this->layout = 'login';

  //  $this->set('menu', $this->Menu->userMenu($this->Auth->user('id')));
}

权限

工具表具有特殊权限,当您向工具添加值时

*/*

用户将能够访问所有应用程序路由

当您向工具添加值时

YourController/*

用户将能够访问所有控制器方法

URL

您可以在以下位置访问用户面板

URL 示例:

<?= 
  $this->Url->build([
      "controller"  => "Users", 
      "action"      => "login", 
      "plugin"      => ""
  ]) 
?>