Advertisement
panegalli

Error Auth

Feb 8th, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. My appController:
  2.  
  3. $this->loadComponent('Auth', [
  4. 'authenticate' => [
  5. 'Form' => [
  6. 'fields' => ['username' => 'login', 'password' => 'senha'],
  7. 'passwordHasher' => [
  8. 'className' => 'Fallback',
  9. 'hashers' => [
  10. 'Default',
  11. 'Weak' => ['hashType' => 'sha1']
  12. ]
  13. ]
  14. ]
  15. ],
  16. 'loginRedirect' => [
  17. 'prefix' => 'admin',
  18. 'controller' => 'Administracao',
  19. 'action' => 'index'
  20. ],
  21. 'logoutRedirect' => [
  22. 'prefix' => false,
  23. 'controller' => 'Paginas',
  24. 'action' => 'index'
  25. ]
  26. ]);
  27.  
  28. My UsersController:
  29.  
  30. public function login(){
  31. if($this->request->is('post')){
  32. //debug($this->request->data(['username']['password']));exit; //this return my username and password(not md5) example felipe/123456
  33. $user = $this->Auth->identify();
  34. if($user){
  35. $this->Auth->setUser($user);
  36. if ($this->Auth->authenticationProvider()->needsPasswordRehash()) {
  37. $user = $this->Users->get($this->Auth->user('id_usuario'));
  38. $user->password = $this->request->data('password');
  39. $this->Users->save($user);
  40. }
  41. return $this->redirect($this->Auth->redirectUrl());
  42. } else {
  43. $this->Flash->error(__('Username or password is incorrect'));
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement