简体   繁体   English

CakePHP中的Auth问题

[英]Problems with Auth in CakePHP

I've been using CakePHP for some time now. 我已经使用CakePHP已有一段时间了。 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. 很难理解Cake Auth的工作原理,但是在过去的几周中,我设法使用了它。

Now to my issue: I have 2 separate tables(Say for Admin Users and Normal Users). 现在是我的问题:我有2个单独的表(对管理员用户和普通用户说)。 Both have different Controllers (Lets say they are AdminsController and UsersController). 两者都有不同的控制器(假设它们是AdminsController和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. 由于我不希望任何普通用户都能访问Admin登录页面,因此我将其与普通用户登录区分开来。

Users login works fine with Auth. 用户登录可以通过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 但是由于某些原因,我现在想为AdminController使用另一个Auth,我无法使用AdminController中的第二个Auth,并且控件会自动转移到Users Login

It would be great if someone could point in the correct direction. 如果有人可以指出正确的方向,那就太好了。 Please! 请!

Thank You. 谢谢。 In advance!! 提前!!

PS : I've also tried using Auth->userModel PS:我也尝试过使用Auth-> userModel

Sorry everyone I was using Auth->userModel slightly wrong way. 对不起,我使用Auth-> userModel的每个人的方法都略有错误。 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"; $ this-> Auth-> userModel =“ User”;

in every controller in beforeFilter() 在beforeFilter()的每个控制器中

enjoy....... 请享用.......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM