CakePHP的验证loginRedirect错误/总是重定向到“用户/登录”,而我把不同的控制器 [英] CakePHP Auth loginRedirect error/always redirect to 'users/login' whereas i put different controller

查看:328
本文介绍了CakePHP的验证loginRedirect错误/总是重定向到“用户/登录”,而我把不同的控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CakePHP的验证loginRedirect错误/总是重定向到用户/登录,而我把不同的控制器。
我的意思是,当我打开网页禁止(不允许/需要登录)

CakePHP Auth loginRedirect error/always redirect to 'users/login' whereas i put different controller. I mean, when i open the forbidden page(not allowed/require login)

$this->Auth->allow('index', 'profile', 'view', 'register');

必须重定向到播放器/指数。我把loginRedirect为玩家,

it must redirect to "players/index". I put the loginRedirect to "players",

'loginRedirect' => array('controller' => 'Players', 'action' => 'index'),

,但它不工作。它总是重定向到用户/密码不的玩家/指数,而我写'loginRedirect'=>阵列('控制'=>'玩家','行动'=>'指数')。

but it doesn't work. It always redirect to "users/login" not "players/index" whereas i write "'loginRedirect' => array('controller' => 'Players', 'action' => 'index')".

这是我的code:

class AppController extends Controller {
public $components = array(
    'Session',
    'Auth'=>array(
        'loginRedirect' => array('controller' => 'Players', 'action' => 'index'),
        'logoutRedirect' => array('controller' => 'Players', 'action' => 'index'),
        'authError'=>"Anda tidak dapat mengakses halaman.",
        'authorize'=>array('Controller')
    )
);

public function isAuthorized($user) {
    return true;
}

public function beforeFilter() {
    $this->Auth->allow('index', 'profile', 'view', 'register');
    $this->set('logged_in', $this->Auth->loggedIn());
    $this->set('current_user', $this->Auth->user());
}}

我的表的名称:玩家

My table's name : players

为什么结果总是重定向到用户/密码不的玩家/或播放器/指数?
请告诉我为什么会这样,我怎么能解决这个问题。谢谢!

why the result's always redirect to "users/login" not "players/" or "players/index"? please tell me why this happens and how i can solve it. Thank you!

推荐答案

你试过为小写控制器的名称?玩家=>玩家

Have you tried to lowercase controller name ? Players => players

'loginRedirect' => array('controller' => 'players', 'action' => 'index'),
'logoutRedirect' => array('controller' => 'players', 'action' => 'index'),

这篇关于CakePHP的验证loginRedirect错误/总是重定向到“用户/登录”,而我把不同的控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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