Это AppController
код:пароля не хэшированные перед хранением в базе данных
public $components = array(
'Session',
'Auth' => array(
'loginRedirect' => array('controller' => 'dashboard', 'action' => 'index'),
'logoutRedirect' => array('controller' => 'admins', 'action' => 'index'),
'authorize' => array('Controller')
)
);
public function beforeFilter()
{
$this->Auth->loginAction = array('controller' => 'admins', 'action' => 'login');
}
public function beforeSave()
{
if(isset($this->data['Admin']['password']))
{
$this->data['Admin']['password'] = AuthComponent::password($this->data['Admin']['password']);
}
return true;
}
И это AdminsController
код:
public $name = 'Admins';
public function beforeFilter()
{
parent::beforeFilter();
$this->Auth->fields = array('username' => 'email', 'password' => 'password');
$this->Auth->allow('signup');
}
public function index()
{
$this->Admin->recursive = 0;
$this->set('admins', $this->Admin->find('all'));
}
public function login()
{
$this->set('title_for_layout', 'Polkadot - Admin Login');
if($this->request->is('post'))
{
if($this->Auth->login())
{
$this->Session->setFlash('Login successfull!');
$this->redirect($this->Auth->redirect());
}
else
{
$this->Session->setFlash('Login failed!');
}
}
}
public function signup()
{
$this->set('title_for_layout', 'Polkadot - Admin Sign Up');
if($this->request->is('post'))
{
if($this->Admin->save($this->request->data))
{
$this->Session->setFlash('Account created successfully!');
$this->redirect(array('action' => 'index'));
}
else
{
$this->Session->setFlash('Account could not be created, please try again!');
}
}
}
Я могу видеть, что учетная запись будет создана, но пароль в база данных - это простой текст. Когда я пытаюсь войти в систему, он терпит неудачу. Что я сделал не так ?
Я хочу index
действие контроллера Dashboard
быть открыто при входе администратора в учетной записи регистрации используется четыре поля ввода:. Имя (текст), электронная почта (текст), пароль (пароль) и password_confirm (пароль). Итак, в форме журнала используются два поля: электронная почта (текст) и пароль (пароль).
CakePHP версия используется 2.3.1
Все оцененная помощи!
[EDIT]: Вот журнал ошибок
2013-04-10 19:31:13 Error: [MissingControllerException] Controller class CssController could not be found.
Exception Attributes: array (
'class' => 'CssController',
'plugin' => NULL,
)
Request URL: /polkapanel/css/cake.generic.css
Stack Trace:
#0 C:\wamp\www\polkapanel\app\webroot\index.php(109): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#1 {main}
2013-04-10 19:31:13 Error: [MissingControllerException] Controller class ImgController could not be found.
Exception Attributes: array (
'class' => 'ImgController',
'plugin' => NULL,
)
Request URL: /polkapanel/img/cake.power.gif
Stack Trace:
#0 C:\wamp\www\polkapanel\app\webroot\index.php(109): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#1 {main}
2013-04-10 19:31:25 Error: [MissingControllerException] Controller class CssController could not be found.
Exception Attributes: array (
'class' => 'CssController',
'plugin' => NULL,
)
Request URL: /polkapanel/css/cake.generic.css
Stack Trace:
#0 C:\wamp\www\polkapanel\app\webroot\index.php(109): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#1 {main}
2013-04-10 19:31:25 Error: [MissingControllerException] Controller class ImgController could not be found.
Exception Attributes: array (
'class' => 'ImgController',
'plugin' => NULL,
)
Request URL: /polkapanel/img/cake.power.gif
Stack Trace:
#0 C:\wamp\www\polkapanel\app\webroot\index.php(109): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#1 {main}
В контроллере нет функции beforeSave(), она должна идти по модели (AppModel или User.ctp, зависит от того, где вы хотите управлять паролями) – Nunser