验证重复的URL控制器 [英] Auth repeats controller in URL
问题描述
我设置了首次验证组件上我的网站,一切似乎除了当我试图访问受限制的页面,做工精细。而不是被重定向到的http://本地主机/ mysite的/用户/登录
,我重定向到的http://本地主机/ mysite的/用户/用户/登录
,控制器名称重复的网址。如何解决这个问题能解决?
我使用CakePHP 2.4.4
的AppController
类AppController的扩展控制器{
公共$组件=阵列('DebugKit.Toolbar',
'会议','验证'=>阵列(
loginRedirect'=>阵列(
控制器=> '管理员',
'行动'=> admin_index
)
logoutRedirect'=>阵列(
控制器=> '用户',
'行动'=> '登录'
)
的LoginAction =>阵列(
控制器=> '用户',
'行动'=> '登录',
'插件'=> '用户'
)
authError'=> NAO TEMpermissão第一个aceder ESTA区。 POR青睐FACA登录。,
'身份验证'=>阵列(
形= GT;阵列(
'域'=>阵列('用户名'= GT;用户名,密码= GT;'密码'
)
'的usermodel'=> '用户'
)
)
'授权'=>阵列('控制'
)
)
);公共职能beforeFilter(){
$this->Auth->allow('index','ShowImages','ShowShowbill','ShowVideos','ShowContactUs','contact','login','DisplayMusic','DisplayEntertainment','DisplayPromotion','DisplayStaff','DisplayEquipments');}
在验证组件,您需要添加unauthorizedRedirect',否则蛋糕试图重定向到/ {应用程序目录}(这是让我头疼昨天)。
公共$组件=阵列(
//你的其他组件
'验证'=>阵列(
//你的其他选项验证
unauthorizedRedirect'=> '/家'
)
);
这将直接任意用户试图访问他们不应该到'YOURDOMAIN /家被允许的页面。
I am setting for the first time the Auth component on my site, and everything seems to work fine except when I try to access a restricted page. Instead of being redirected to http://localhost/MySite/users/login
, I get redirected to http://localhost/MySite/users/users/login
, the controller name is repeated on the url. How can this issue be fixed?
I am using CakePhp 2.4.4
AppController
class AppController extends Controller {
public $components = array('DebugKit.Toolbar',
'Session','Auth' => array(
'loginRedirect'=> array(
'controller' => 'admins',
'action' => 'admin_index'
),
'logoutRedirect' => array(
'controller' => 'users',
'action' => 'login'
),
'loginAction' => array(
'controller' => 'users',
'action' => 'login',
'plugin' => 'users'
),
'authError' => 'Não tem permissão para aceder a esta área. Por favor faça login.',
'authenticate' => array(
'Form' => array(
'fields' => array('username' => 'username', 'password' => 'password'
),
'userModel' => 'User'
)
),
'authorize' =>array('Controller'
)
)
);
public function beforeFilter(){
$this->Auth->allow('index','ShowImages','ShowShowbill','ShowVideos','ShowContactUs','contact','login','DisplayMusic','DisplayEntertainment','DisplayPromotion','DisplayStaff','DisplayEquipments');
}
In Auth component you need to add 'unauthorizedRedirect' otherwise Cake tries to redirect to /{app-directory} (this was giving me a headache yesterday).
public $components = array(
//your other components
'Auth' => array(
//your other options for Auth
'unauthorizedRedirect' => '/home'
)
);
This would direct any user trying to access a page they shouldn't be allowed on to 'yourDomain/home'.
这篇关于验证重复的URL控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!