php - 如何在 CakePHP 2.0.4 中为 Auth 组件使用不同的模型?

标签 php cakephp authentication cakephp-2.0

这看起来是一件微不足道的事情,但我真的找不到哪里可以改变它。 我想使用我的“玩家”模型而不是用户,但每次我进入/players/login 时,它都会将我重定向到“缺少 Controller ”页面并将更改链接到/users/login。

我尝试过:

public $components = array(
    'Session',
    'Auth' => array(
        'authenticate' => array('all' => array('userModel' => 'Player'))
     )
);

function beforeFilter() {
    $this->Auth->authenticate = array('all' => array('userModel' => 'Player'));
}

编辑:已解决

'loginAction' => array('controller' => 'players', 'action' => 'login')

我认为在 $components 数组中有所帮助:D

最佳答案

我猜问题是您没有提供身份验证系统。您正在提供一些要在将选择的所有身份验证系统中使用的设置,但您还没有选择一项(您必须至少提供一项,例如 Form、Basic、Digest 等)。

$this->Auth->authenticate = array(
    'all' => array('userModel' => 'Member'),
    'Form',
    'Basic'
);

(或 $components 数组中的相同内容)

关于php - 如何在 CakePHP 2.0.4 中为 Auth 组件使用不同的模型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8996162/

相关文章:

php - BuddyPress,发布新故事时发送通知

php - 为 WooCommerce 中有限数量的现有订单更新多个元数据

ssl - jboss 5.1 ssl 客户端认证

http - 当 API 使用 Introspection 进行 HTTP token 身份验证时,如果 Introspection 服务器关闭或返回 500,它应该返回什么?

mysql - 为 order by 子句准备 cakephp 案例

c# - 如何记住登录表单的用户名或密码

javascript - Laravel ajax post 方法给出 MethodNotAllowedHttpException

PHP 和 MySql 导航问题...与日期

php - 多级 "has many"关系

php - 如何处理 MySQL 中的动态列