CakePHP - 'AuthComponent'具有不同的型号名称(不是'User') [英] CakePHP - 'AuthComponent' with a different model name (not 'User')

查看:101
本文介绍了CakePHP - 'AuthComponent'具有不同的型号名称(不是'User')的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在CakePHP中使用 AuthComponent 模型(及其相应的表)命名为Admin('admins'表在数据库中)。我使用 app_controller BeforeFilter()函数中的 $ this-> Auth-> userModel ='Admin'; >,表示我没有使用deafult模型用户

I want to use AuthComponent in CakePHP with a model (and its corresponding table) named Admin ('admins' table in the database). I've used $this->Auth->userModel = 'Admin'; as the documenation says in the BeforeFilter() function of the app_controller, to indicate that I'm not using the deafult model User.

但是,我是在错误的地方做,还是有其他需要做的,因为我不能使身份验证工作(登录功能在我的 admins_controller.php )。其他功能运作良好(例如添加功能)。

However, either I'm doing it in the wrong place or there's something else that needs to be done, because I can't make the authentication to work (the login function in my admins_controller.php). The rest of functions work well (for example the add function).

如果我使用用户我的模型与用户表,它的工作完美。如何解决这个问题?

If I use the name User for my model with a users table, it works perfectly. How do I fix this problem?

推荐答案

确保在您的电脑上调用 parent :: beforeFilter() AdminController :: beforeFilter()

Make sure you call parent::beforeFilter() in your AdminController::beforeFilter().

这篇关于CakePHP - 'AuthComponent'具有不同的型号名称(不是'User')的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆