Commit f6d16bebef0d48420b7d726ef8e5161ed4411d61
1 parent
2e309a73
Exists in
master
and in
1 other branch
bugfixing...
Showing
1 changed file
with
42 additions
and
14 deletions
Show diff stats
src/Controller/UsersController.php
... | ... | @@ -199,7 +199,7 @@ class UsersController extends AppController { |
199 | 199 | //$this->Auth->setUser($user); |
200 | 200 | $this->LdapAuth->setUser($user); |
201 | 201 | |
202 | - //debug($user); | |
202 | + debug($user); | |
203 | 203 | /* Voici ce que contient $user : |
204 | 204 | [ |
205 | 205 | 'sn' => [ |
... | ... | @@ -222,13 +222,14 @@ class UsersController extends AppController { |
222 | 222 | |
223 | 223 | ///if (SessionTimeoutON) |
224 | 224 | $this->statsUpdateForCurrentUserWhen(null,'sur login'); |
225 | + //$this->statsUpdateForCurrentUserWhen($user,'sur login'); | |
225 | 226 | //$this->statsUpdateForCurrentUserOnLogin(); |
226 | 227 | //exit; |
227 | 228 | |
228 | 229 | // On va maintenant à la page qui etait demandée |
229 | 230 | //return $this->redirect($this->Auth->redirectUrl()); |
230 | 231 | return $this->redirect($this->LdapAuth->redirectUrl()); |
231 | - } | |
232 | + } // login OK | |
232 | 233 | |
233 | 234 | } // POST |
234 | 235 | } // login() |
... | ... | @@ -282,13 +283,37 @@ class UsersController extends AppController { |
282 | 283 | return $user_infos ? $user_infos['sn'][0].' '.$user_infos['givenname'][0] : 'Name Firstname'; |
283 | 284 | } |
284 | 285 | private function _getCurrentUserLoginFromSession($user_infos = null) { |
285 | - if (!$user_infos) $user_infos = $this->_getCurrentUserInfosFromSession(); | |
286 | - if (! $user_infos) throw new \ErrorException("Pas d'utilisateur défini dans la session !!!"); | |
287 | - //debug($user_infos); | |
286 | + debug($user_infos); | |
287 | + if (empty($user_infos)) $user_infos = $this->_getCurrentUserInfosFromSession(); | |
288 | + debug($user_infos); | |
289 | + if (empty($user_infos)) throw new \ErrorException("Pas d'utilisateur défini dans la session (user_infos empty) !!!"); | |
290 | + //if (!$user_infos) $user_infos = $this->_getCurrentUserInfosFromSession(); | |
291 | + //if (!$user_infos) throw new \ErrorException("Pas d'utilisateur défini dans la session !!!"); | |
292 | + /* | |
293 | + debug($user_infos); | |
294 | + => ce qui donne : | |
295 | + [ | |
296 | + 'sn' => [ | |
297 | + (int) 0 => 'Utilisateur' | |
298 | + ], | |
299 | + 'mail' => [ | |
300 | + (int) 0 => 'newuser@email.com' | |
301 | + ], | |
302 | + 'givenname' => [ | |
303 | + (int) 0 => 'Newuser' | |
304 | + ], | |
305 | + 'uid' => [ | |
306 | + (int) 0 => 'newuser' | |
307 | + ], | |
308 | + 'userpassword' => [ | |
309 | + (int) 0 => '$2y$10$LZzpws3oDidBcqO/Fy1RTedLLk3ENTmplny5J7bZ6R1PqFoGOw3Ma' | |
310 | + ] | |
311 | + ] | |
312 | + */ | |
288 | 313 | // "Pallier Etienne" |
289 | 314 | //$user_login_field_name = $this->authenticationType; |
290 | 315 | //$user_login_field_name = isset($user_infos['uid']) ? 'uid' : 'samaccountname'; |
291 | - $user_login_field_name = isset($user_infos[self::DEFAULT_AUTH_TYPE]) ? self::DEFAULT_AUTH_TYPE : 'samaccountname'; | |
316 | + $user_login_field_name = isset($user_infos[self::DEFAULT_AUTH_TYPE]) ? self::DEFAULT_AUTH_TYPE : 'samaccountname'; // 'uid' ou 'samaccountname'... | |
292 | 317 | if (! isset($user_infos[$user_login_field_name])) { |
293 | 318 | debug($user_login_field_name); |
294 | 319 | debug($user_infos); |
... | ... | @@ -306,6 +331,8 @@ class UsersController extends AppController { |
306 | 331 | } |
307 | 332 | private function _getCurrentUserEntityFromSession($session_user = null) { |
308 | 333 | $user_login = $this->_getCurrentUserLoginFromSession($session_user); |
334 | + debug($user_login); // le login | |
335 | + if (is_null($user_login)) throw new \ErrorException("Pas de user login trouvé dans la session (user_login is null)"); | |
309 | 336 | return $this->Users->find()->where(['username'=>$user_login])->first(); |
310 | 337 | } |
311 | 338 | |
... | ... | @@ -316,7 +343,8 @@ class UsersController extends AppController { |
316 | 343 | */ |
317 | 344 | public function statsUpdateForCurrentUserWhen($session_user=null, $event_name) { |
318 | 345 | $user_id = ($event_name=='sur logout') ? $this->u->id : $this->_getCurrentUserEntityFromSession($session_user)->id; |
319 | - //debug($user); | |
346 | + debug($user_id); // l'id du user dans table users | |
347 | + if (is_null($user_id)) throw new \ErrorException("Pas de user trouvé dans la session (user_id is null)"); | |
320 | 348 | $this->Users->Stats->updateForUserWhen($user_id, $event_name); |
321 | 349 | } |
322 | 350 | |
... | ... | @@ -324,7 +352,7 @@ class UsersController extends AppController { |
324 | 352 | /** |
325 | 353 | * Index method |
326 | 354 | * |
327 | - * @return \Cake\Network\Response|null | |
355 | + * @return \Cake\Http\Response|null | |
328 | 356 | */ |
329 | 357 | public function index() { |
330 | 358 | |
... | ... | @@ -407,7 +435,7 @@ class UsersController extends AppController { |
407 | 435 | /** |
408 | 436 | * Index_recap method |
409 | 437 | * |
410 | - * @return \Cake\Network\Response|null | |
438 | + * @return \Cake\Http\Response|null | |
411 | 439 | */ |
412 | 440 | /* (EP202010 fusionnée avec index()) |
413 | 441 | public function indexRecap() |
... | ... | @@ -460,7 +488,7 @@ class UsersController extends AppController { |
460 | 488 | * |
461 | 489 | * @param string|null $id |
462 | 490 | * User id. |
463 | - * @return \Cake\Network\Response|null | |
491 | + * @return \Cake\Http\Response|null | |
464 | 492 | * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. |
465 | 493 | */ |
466 | 494 | public function view($id = null) |
... | ... | @@ -484,7 +512,7 @@ class UsersController extends AppController { |
484 | 512 | /** |
485 | 513 | * Add method |
486 | 514 | * |
487 | - * @return \Cake\Network\Response|void Redirects on successful add, renders view otherwise. | |
515 | + * @return \Cake\Http\Response|void Redirects on successful add, renders view otherwise. | |
488 | 516 | */ |
489 | 517 | public function add() |
490 | 518 | { |
... | ... | @@ -570,8 +598,8 @@ class UsersController extends AppController { |
570 | 598 | * |
571 | 599 | * @param string|null $id |
572 | 600 | * User id. |
573 | - * @return \Cake\Network\Response|void Redirects on successful edit, renders view otherwise. | |
574 | - * @throws \Cake\Network\Exception\NotFoundException When record not found. | |
601 | + * @return \Cake\Http\Response|void Redirects on successful edit, renders view otherwise. | |
602 | + * @throws \Cake\Http\Exception\NotFoundException When record not found. | |
575 | 603 | */ |
576 | 604 | public function edit($id = null) |
577 | 605 | { |
... | ... | @@ -643,7 +671,7 @@ class UsersController extends AppController { |
643 | 671 | * |
644 | 672 | * @param string|null $id |
645 | 673 | * User id. |
646 | - * @return \Cake\Network\Response|null Redirects to index. | |
674 | + * @return \Cake\Http\Response|null Redirects to index. | |
647 | 675 | * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. |
648 | 676 | */ |
649 | 677 | public function delete($id = null) | ... | ... |