Когда я нажимаю кнопку входа в форму, ничего не происходит. Он не перенаправляет на / merry_parents / report_card. Я указал $ this-> Auth-> loginRedirect в beforeFilter. Кто-нибудь знает, что я делаю не так? заранее спасибо.
Ниже приведен мой контроллер merry_parents, представление входа в систему и представление report_card
app_controller.php
class AppController extends Controller {
var $components=array('Auth','Session');
function beforeFilter(){
if (isset($this->Auth)){
$this->Auth->userModel='MerryParent';
$this->Auth->loginAction=array('controller'=>'merry_parents','action'=>'login');
$this->Auth->loginRedirect=array('controller'=>'merry_parents','action'=>'report_card');
$this->Auth->allow('signup','login','logout');
$this->Auth->authorize='controller';
//$this->Auth->actionPath='controllers/';
}
else
$this->Session->setFlash('Auth has not been set');
}
function isAuthorized(){
return true;
}
}
merry_parents_controller.php
class MerryParentsController extends AppController{
var $name='MerryParents';
var $components=array('Acl','Auth','Session');
function report_card(){
}
function register(){
}
function login(){
}
function logout(){
$this->redirect($this->Auth->logout());
}
function signup(){
print_r($this->data);
if (!empty($this->data)){
//$this->Auth->password($this->data['MerryParent']['password2'] used to get what the hashed password2 would look like.
$this->MerryParent->set($this->data);
//validates calls invalidFields methods which in turn populates validationErrors arrays. Validates is used to validate a record prior to updating. Needed only when you want to update certain fields in an existing record.
if ($this->MerryParent->validates(array('fieldList'=>array('username','email','password','password2')))){
if ($this->data['MerryParent']['password']==$this->Auth->password($this->data['MerryParent']['password2'])){
$this->MerryParent->id=$this->MerryParent->field('id',
array('MerryParent.username'=>$this->data['MerryParent']['username'],
'MerryParent.email'=>$this->data['MerryParent']['email'])
);
echo $this->MerryParent->id;
//die(debug($this->MerryParent->validationErrors));
if ($this->MerryParent->save($this->data,false))//record with $this->MerryParent->id is updated
{
$this->Auth->login($this->data); //automatically logs a user in after registration
$this->redirect('/merry_parents/report_card');
}
else
echo $this->Session->setFlash(__('Your admission could not be saved, please try again!',true));
}//end if ($this->data['MerryParent']['password']....
else
echo $this->Session->setFlash('Typed passwords did not match');
}//if ($this->MerryParent->validates
}//end if (!empty($this->data))
}
}
?>
login.ctp
<?php
echo $this->Form->create('MerryParent',array('action'=>'login'));
echo $this->Form->input('username',array('label'=>'Name'));
echo $this->Form->input('password', array('value'=>''));
echo $this->Form->end('Login');
?>
report_card.ctp
<?php
echo 'HALLO';
?>