Я только начинаю кодирование с помощью cakePHP. Я закодировал и попытался написать страницу входа и аутентификации.
Я попытался это:Ошибка входа в cakePHP
class AppController extends Controller
{
public function beforeFilter()
{
parent::beforeFilter();
if ($this->request->action != 'login' && !$this->Session->check('profile'))
{
$this->Session->setFlash('You are not logged in');
$this->redirect(array(
'controller' => 'profiles',
'action' => 'login'
));
}
}
}
Моя проблема заключается в том, что я не могу войти. Я всегда получаю
«Вы не вошли в систему»
Без этого кода, он работает, но не Протек другие страницы.
Моего routes.php
Router::connect('/', array('controller' => 'profiles', 'action' => 'login'));
Мой ProfilesController.php
public function login()
{
if ($this->request->is('post'))
{
$profile = $this->Profile->find('first', array(
'conditions' => array(
'name' => $this->request->data('Profile.name'),
'password' => $this->request->data('Profile.password')
)
));
if ($profile)
{
$this->Session->write('Profile',$profile);
$this->redirect(array('controller' => 'Projects',
'action' => 'index'));
}
$this->Session->setFlash('Profile and Password does not match!');
}
}