私はCakePHP2.2.4を使用しており、AtuhComponenetでの作業を開始しました。
これは私のAppControllerです:
class AppController extends Controller {
public $components = array('Auth', 'Session');
public function beforeFilter() {
$this->Auth->authorize = array('Controller');
$this->Auth->authenticate = array(
'Form' => array (
'scope' => array('User.active' => 1),
'fields' => array('username' => 'email', 'password' => 'password'),
)
);
}
public function isAuthorized($user) {
debug($user);
return true;
}
}
これは私のUser.phpモデルです
class User extends AppModel {
public $name = 'User';
/* Relazioni */
public $hasOne = 'Profile';
public $belongsTo = 'Role';
public $hasMany = array(
'Lead' => array(
'className' => 'Lead'
)
);
}
これは私のUserController.phpです
<?php
App::uses('AppController', 'Controller');
class UsersController extends AppController
{
public $name = 'Users';
public $uses = array();
public function beforeFilter()
{
parent::beforeFilter();
}
public function login()
{
if ($this->request->is('post'))
{
if ($this->Auth->login())
{
debug('Logged');
}
else
{
$this->Session->setFlash('Login non autorizzato', 'default', array('class' => 'errore'), 'login');
}
}
}
public function logout()
{
$this->redirect($this->Auth->logout());
}
}
Auth Componentの使用に奇妙な問題があります。これは、レイアウトの最後にsql_dump要素があり、クエリが出力されないためです。
ただし、正しい値を入力するとログインしません
Authコンポーネントが機能しないのはなぜですか?
編集:
リクエストのデータは次のとおりです。
Array
(
[User] => Array
(
[email] => test@test.it
[pwd] => abc
)
)