maymeow/

cakephp-identity

此包已被放弃,不再维护。未建议替代包。

CakePHP 的身份插件

安装: 110

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 0

开放问题: 0

类型:cakephp-plugin

v1.1 2019-04-16 14:14 UTC

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();