diff --git a/src/Controller/UsersController.php b/src/Controller/UsersController.php index d6a216b..e3beb4a 100755 --- a/src/Controller/UsersController.php +++ b/src/Controller/UsersController.php @@ -199,7 +199,7 @@ class UsersController extends AppController { //$this->Auth->setUser($user); $this->LdapAuth->setUser($user); - //debug($user); + debug($user); /* Voici ce que contient $user : [ 'sn' => [ @@ -222,13 +222,14 @@ class UsersController extends AppController { ///if (SessionTimeoutON) $this->statsUpdateForCurrentUserWhen(null,'sur login'); + //$this->statsUpdateForCurrentUserWhen($user,'sur login'); //$this->statsUpdateForCurrentUserOnLogin(); //exit; // On va maintenant à la page qui etait demandée //return $this->redirect($this->Auth->redirectUrl()); return $this->redirect($this->LdapAuth->redirectUrl()); - } + } // login OK } // POST } // login() @@ -282,13 +283,37 @@ class UsersController extends AppController { return $user_infos ? $user_infos['sn'][0].' '.$user_infos['givenname'][0] : 'Name Firstname'; } private function _getCurrentUserLoginFromSession($user_infos = null) { - if (!$user_infos) $user_infos = $this->_getCurrentUserInfosFromSession(); - if (! $user_infos) throw new \ErrorException("Pas d'utilisateur défini dans la session !!!"); - //debug($user_infos); + debug($user_infos); + if (empty($user_infos)) $user_infos = $this->_getCurrentUserInfosFromSession(); + debug($user_infos); + if (empty($user_infos)) throw new \ErrorException("Pas d'utilisateur défini dans la session (user_infos empty) !!!"); + //if (!$user_infos) $user_infos = $this->_getCurrentUserInfosFromSession(); + //if (!$user_infos) throw new \ErrorException("Pas d'utilisateur défini dans la session !!!"); + /* + debug($user_infos); + => ce qui donne : + [ + 'sn' => [ + (int) 0 => 'Utilisateur' + ], + 'mail' => [ + (int) 0 => 'newuser@email.com' + ], + 'givenname' => [ + (int) 0 => 'Newuser' + ], + 'uid' => [ + (int) 0 => 'newuser' + ], + 'userpassword' => [ + (int) 0 => '$2y$10$LZzpws3oDidBcqO/Fy1RTedLLk3ENTmplny5J7bZ6R1PqFoGOw3Ma' + ] + ] + */ // "Pallier Etienne" //$user_login_field_name = $this->authenticationType; //$user_login_field_name = isset($user_infos['uid']) ? 'uid' : 'samaccountname'; - $user_login_field_name = isset($user_infos[self::DEFAULT_AUTH_TYPE]) ? self::DEFAULT_AUTH_TYPE : 'samaccountname'; + $user_login_field_name = isset($user_infos[self::DEFAULT_AUTH_TYPE]) ? self::DEFAULT_AUTH_TYPE : 'samaccountname'; // 'uid' ou 'samaccountname'... if (! isset($user_infos[$user_login_field_name])) { debug($user_login_field_name); debug($user_infos); @@ -306,6 +331,8 @@ class UsersController extends AppController { } private function _getCurrentUserEntityFromSession($session_user = null) { $user_login = $this->_getCurrentUserLoginFromSession($session_user); + debug($user_login); // le login + if (is_null($user_login)) throw new \ErrorException("Pas de user login trouvé dans la session (user_login is null)"); return $this->Users->find()->where(['username'=>$user_login])->first(); } @@ -316,7 +343,8 @@ class UsersController extends AppController { */ public function statsUpdateForCurrentUserWhen($session_user=null, $event_name) { $user_id = ($event_name=='sur logout') ? $this->u->id : $this->_getCurrentUserEntityFromSession($session_user)->id; - //debug($user); + debug($user_id); // l'id du user dans table users + if (is_null($user_id)) throw new \ErrorException("Pas de user trouvé dans la session (user_id is null)"); $this->Users->Stats->updateForUserWhen($user_id, $event_name); } @@ -324,7 +352,7 @@ class UsersController extends AppController { /** * Index method * - * @return \Cake\Network\Response|null + * @return \Cake\Http\Response|null */ public function index() { @@ -407,7 +435,7 @@ class UsersController extends AppController { /** * Index_recap method * - * @return \Cake\Network\Response|null + * @return \Cake\Http\Response|null */ /* (EP202010 fusionnée avec index()) public function indexRecap() @@ -460,7 +488,7 @@ class UsersController extends AppController { * * @param string|null $id * User id. - * @return \Cake\Network\Response|null + * @return \Cake\Http\Response|null * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. */ public function view($id = null) @@ -484,7 +512,7 @@ class UsersController extends AppController { /** * Add method * - * @return \Cake\Network\Response|void Redirects on successful add, renders view otherwise. + * @return \Cake\Http\Response|void Redirects on successful add, renders view otherwise. */ public function add() { @@ -570,8 +598,8 @@ class UsersController extends AppController { * * @param string|null $id * User id. - * @return \Cake\Network\Response|void Redirects on successful edit, renders view otherwise. - * @throws \Cake\Network\Exception\NotFoundException When record not found. + * @return \Cake\Http\Response|void Redirects on successful edit, renders view otherwise. + * @throws \Cake\Http\Exception\NotFoundException When record not found. */ public function edit($id = null) { @@ -643,7 +671,7 @@ class UsersController extends AppController { * * @param string|null $id * User id. - * @return \Cake\Network\Response|null Redirects to index. + * @return \Cake\Http\Response|null Redirects to index. * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. */ public function delete($id = null) -- libgit2 0.21.2