我的驗證組件工作良好,但它複製了我的CakePHP所在的文件夾。例如,我的整個CakePHP安裝位於localhost/rh/
中,但登錄重定向時它會將用戶發送到localhost/rh/rh/controller
。有什麼想法嗎?Cakephp驗證嘗試調用不存在的控制器
的AppController:
class AppController extends Controller {
public $components = array(
'Session',
'Auth' => array(
'loginRedirect' => array('controller' => 'users', 'action' => 'index'),
'logoutRedirect' => array('controller' => 'users', 'action' => 'index'),
'authError' => "You are not authorized to access that page",
'authorize' => array('Controller')
)
);
public function isAuthorized($user) {
return true;
}
public function beforeFilter() {
$this->Auth->allow('index', 'view');
}
}
UserController中:
class UsersController extends AppController {
//before filter to allow users to register
public function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow('add'); // Letting users register themselves
}
//login action
public function login() {
if ($this->request->is('post')) {
if ($this->Auth->login()) {
$this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash(__('Invalid username or password, try again'));
}
}
}
//logout action
public function logout() {
$this->redirect($this->Auth->logout());
}
什麼版本的蛋糕您使用的是? – AD7six
AD7six:cakephp版本2.3.7 –