Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- My appController:
- $this->loadComponent('Auth', [
- 'authenticate' => [
- 'Form' => [
- 'fields' => ['username' => 'login', 'password' => 'senha'],
- 'passwordHasher' => [
- 'className' => 'Fallback',
- 'hashers' => [
- 'Default',
- 'Weak' => ['hashType' => 'sha1']
- ]
- ]
- ]
- ],
- 'loginRedirect' => [
- 'prefix' => 'admin',
- 'controller' => 'Administracao',
- 'action' => 'index'
- ],
- 'logoutRedirect' => [
- 'prefix' => false,
- 'controller' => 'Paginas',
- 'action' => 'index'
- ]
- ]);
- My UsersController:
- public function login(){
- if($this->request->is('post')){
- //debug($this->request->data(['username']['password']));exit; //this return my username and password(not md5) example felipe/123456
- $user = $this->Auth->identify();
- if($user){
- $this->Auth->setUser($user);
- if ($this->Auth->authenticationProvider()->needsPasswordRehash()) {
- $user = $this->Users->get($this->Auth->user('id_usuario'));
- $user->password = $this->request->data('password');
- $this->Users->save($user);
- }
- return $this->redirect($this->Auth->redirectUrl());
- } else {
- $this->Flash->error(__('Username or password is incorrect'));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement