Моя ссылка для входа на страницу регистрации не приводит меня к странице входа. Вместо этого он ведет меня на страницу report_card, которая является страницей loginRedirect.
В beforeFilter я установил autoRedirect на false, потому что я устанавливаю куки в функции входа в систему, а затем я устанавливаю $ this-> redirect ($ this-> Auth-> redirect ());
Может кто-нибудь, пожалуйста, помогите мне? заранее спасибо.
мой код:
register.ctp
<?php
echo $this->Html->link('Sign Up','/merry_parents/signup',array()).' for new user |'.$this->Html->link('Login','/merry_parents/login',array()).' for existing user';
?>
app_controller.php
class AppController extends Controller {
var $components=array('Auth','Session','Cookie');
function beforeFilter(){
if (isset($this->Auth)){
$this->Auth->userModel='MerryParent';
$this->Auth->loginAction=array('controller'=>'merry_parents','action'=>'login');
//var_dump($this->data);
$this->Auth->loginRedirect=array('controller'=>'merry_parents','action'=>'report_card');
$this->Auth->allow('signup','login','logout','display');
$this->Auth->authorize='controller';
}
else
$this->Session->setFlash('Auth has not been set');
}
function isAuthorized(){
return true;
}
merry_parents_controller.php
<?php
class MerryParentsController extends AppController{
var $name='MerryParents';
var $helpers=array('Html','Form');
function beforeFilter(){
$this->Auth->autoRedirect=false;
parent::beforeFilter();
}
function report_card(){
}
function register(){
}
function login(){
if ($this->Auth->user()){
if (!empty($this->data)){
$this->MerryParent->id=$this->MerryParent->field('id',array(
'MerryParent.username'=>$this->data['MerryParent']['username'],
'MerryParent.password'=>$this->data['MerryParent']['password']
)
);
echo 'id: '.$this->MerryParent->id;
$this->Cookie->write('MerryParent.id',$this->MerryParent->id,false,0);
$this->set('id',$this->Cookie->read('MerryParent.id'));
}
$this->redirect($this->Auth->redirect());
}
}
report_card.ctp
<?php
var_dump($this->data);
echo 'HALLO';
if (isset($id))
echo $id;
else
echo 'id has not been set';
?>