CakePHP 中的身份验证问题
我使用 CakePHP 一段时间了。但有些问题我还是没能自己解决。 很难理解 Cake Auth 的工作原理,但在过去的几周里我已经成功地使用它了。
现在我的问题是: 我有 2 个单独的表(例如管理员用户和普通用户)。两者都有不同的控制器(假设它们是 AdminsController 和 UsersController)。 现在我已经毫无困难地完成了用户模块。用户登录和管理员登录是不同的视图。由于我不希望任何普通用户能够访问管理员登录页面,因此我将其与普通用户登录分开。
用户登录与身份验证工作正常。但现在我想对 AdminController 使用另一个身份验证,由于某种原因,我无法使用 AdminController 的第二个身份验证,并且控制权会自动转移到用户登录,
如果有人能指出正确的方向,那就太好了。请!
谢谢。提前!!
PS:我也尝试过使用 Auth->userModel
I've been using CakePHP for some time now. But I still fail to solve some issues on my own.
Its been difficult to understand how Cake Auth works but in these past few weeks I've managed to work with it.
Now to my issue:
I have 2 separate tables(Say for Admin Users and Normal Users). Both have different Controllers (Lets say they are AdminsController and UsersController).
Now I have completed Users module without any trouble. Users login and Admin Login are different views. As I dont want any normal User to be able to get their hands on Admin login page I've kept it separate from normal user login.
Users login works fine with Auth. But now I want to use another Auth for AdminController for some reason I am unable to make use the second Auth from AdminController and control automatically transfers to the Users Login
It would be great if someone could point in the correct direction. Please!
Thank You. In advance!!
P.S : I've also tried using Auth->userModel
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
抱歉大家,我使用 Auth->userModel 的方式略有错误。
我将其添加到我的管理控制器中,但没有添加到用户控制器中,因此如果您来这里寻找答案,请
使用$this->Auth->userModel="User";
在每个控制器中 beforeFilter()
享受......
Sorry everyone I was using Auth->userModel slightly wrong way.
I was adding it to my Admin Controller but not in User Controller so if you came here looking for an answer please use
$this->Auth->userModel="User";
in every controller in beforeFilter()
enjoy.......