我在Cakephp 2.4中遇到Auth问题,无法登录,我在代码中找不到错误
我的AppController
用户模型
我的登录方法
的
的public function cpadmin_login()
{
$this->pageTitle = __('Login page', true);
if ($this->request->is('post')) {
if ($this->Auth->login()) {
return $this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash(__('Username or password is incorrect'), 'default', array(), 'auth');
}
}
}
的
虽然尝试通过用户名/密码登录,但事情不会发生,而且sql日志没有密码检查
sql log
SELECT `User`.`id`, `User`.`name`, `User`.`username`, `User`.`password`, `User`.`email`, `User`.`role_id`, `User`.`active`, `User`.`created`, `Role`.`id`, `Role`.`name`, `Role`.`roles` FROM `cairotweet`.`users` AS `User` LEFT JOIN `cairotweet`.`roles` AS `Role` ON (`User`.`role_id` = `Role`.`id`) WHERE `User`.`username` = 'admin' AND `User`.`active` = 1 LIMIT 1
答案 0 :(得分:1)
我建议您从cakePHP网站上查看教程简单身份验证和授权应用程序:
http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html http://book.cakephp.org/2.0/en/tutorials-and-examples/simple-acl-controlled-application/simple-acl-controlled-application.html http://book.cakephp.org/2.0/en/tutorials-and-examples/simple-acl-controlled-application/part-two.html
按照所有步骤,您将快速配置Acl和Auth,数据库,控制器和模型。