maymeow / cakephp-identity
此包已被放弃,不再维护。未建议替代包。
CakePHP 的身份插件
v1.1
2019-04-16 14:14 UTC
Requires
- cakephp/cakephp: ^3.5
Requires (Dev)
- phpunit/phpunit: ^5.7.14|^6.0
This package is auto-updated.
Last update: 2020-05-31 12:58:49 UTC
README
安装
您可以使用 composer 将此插件安装到您的 CakePHP 应用程序中。
安装 composer 包的推荐方法是
composer require maymeow/cakephp-identity
配置
在 Application.php
中使用以下代码加载插件
$this->addPlugin('Identity', ['bootstrap' => false, 'routes' => true]);
将以下代码添加到 AppController.php
$this->loadComponent('Auth', [ //'authorize'=> 'Controller', 'authenticate' => [ 'Form' => [ 'userModel' => 'Identity.Users', // use this to change default auth model 'fields' => [ 'username' => 'email', 'password' => 'password' ] ] ], 'loginAction' => [ 'controller' => 'Users', 'action' => 'login', 'plugin' => 'Identity', 'prefix' => false ], // If unauthorized, return them to page they were just on 'unauthorizedRedirect' => $this->referer() ]); $this->Auth->deny();