Authentication 当我尝试$this时->;认证->;user(),但当我添加id$this->;认证->;用户(';id';)它不';它是空的
$this->Auth->user('id')始终为空 AppController代码:Authentication 当我尝试$this时->;认证->;user(),但当我添加id$this->;认证->;用户(';id';)它不';它是空的,authentication,cakephp,login,Authentication,Cakephp,Login,$this->Auth->user('id')始终为空 AppController代码: <?php App::uses('AuthComponent', 'Controller/Component'); App::uses('Controller', 'Controller'); class AppController extends Controller { //public $components = array('DebugKit.Toolbar','Session');
<?php
App::uses('AuthComponent', 'Controller/Component');
App::uses('Controller', 'Controller');
class AppController extends Controller {
//public $components = array('DebugKit.Toolbar','Session');
public $components = array(
'Acl',
'Flash',
'Auth' => array(
'authorize' => array(
'Actions' =>
array('actionPath' => 'controllers','action'=>'index')
)
),
'Session'
);
public $helpers = array('Html', 'Form', 'Session');
public function beforeFilter() {
//Configure AuthComponent
$this->Auth->allow();
$this->Auth->loginAction = array(
'controller' => 'personnes',
'action' => 'login'
);
$this->Auth->logoutRedirect = array(
'controller' => 'personnes',
'action' => 'login'
);
$this->Auth->loginRedirect = array(
'controller' => 'biens',
'action' => 'index'
); }}
bienscontroller
public function index( ) {
$this->Bien->recursive = 0;
$this->paginate = array(
'paramType' => 'querystring',
'limit' => 5
);
$biens = $this->paginate('Bien');
$this->set(compact('biens'));
$user = $this->Auth->user('id');
Debugger::dump($user);
}
人员模型`
<?php
App::uses('AuthComponent', 'Controller/Component');
App::uses('AppModel', 'Model');
class Personne extends AppModel {`
public function beforeSave($options = array()) {
$this->data['Personne']['mdp'] =
AuthComponent::password($this>data['Personne']['mdp']);
return true;
}
当我尝试$this->Auth->user()时,它工作,但当我添加id$this->Auth->user('id')时,它不工作,它是空的使用$this->Auth->user()
?数组((int)0=>数组('Personne'=>数组(“登录”=>“****”、“id”=>“2”、“指定”=>“管理员”、“日期”=>“2016-03-16”、“地址”=>“rue”、“telFixe”=>“266666”、“telMobile1”=>“88888”、“telMobile2”=>“9999”、“电子邮件”=>)wahiba@gmail.com“,'mdp'=>'wah','LIENPHOTOPERNATIONS'=>'wah.jpg','idVille'=>'1'),'Ville'=>数组('idVille'=>'1'、'nomVille'=>'Hammamet'、'lienImageVille'=>'c://--'、'affichableVille'=>true、'codePostalVille'=>'8050'、'idPays'=>'1')、'bienspersone'=>array()、'Bien'=>array())那么它不应该是$this->Auth->user(0)['persone'['id'];???
<?php
App::uses('AuthComponent', 'Controller/Component');
App::uses('AppModel', 'Model');
class Personne extends AppModel {`
public function beforeSave($options = array()) {
$this->data['Personne']['mdp'] =
AuthComponent::password($this>data['Personne']['mdp']);
return true;
}