Guest User

whats wrong

a guest
Apr 22nd, 2015
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1. // AppController.php
  2. public function initialize() {
  3.         parent::initialize();
  4.         $this->loadComponent('Flash');
  5.         $this->loadComponent('Auth', [
  6.             'loginRedirect' => ['controller' => 'Users', 'action' => 'profile'],
  7.             'logoutRedirect' => ['controller' => 'Search', 'action' => 'index'],
  8.             'loginAction' => ['controller' => 'Users','action' => 'login'],
  9.         ]);
  10.     }
  11.  
  12. // UsersController.php
  13.  
  14.  public function login() {
  15.         /*$user = $this->Users->newEntity(['id' => 1]);
  16.         $user = $this->Users->patchEntity($user, ['password' => '123456']);
  17.         $this->Users->save($user);*/
  18.         if ($this->request->is('post')) {
  19.             $user = $this->Auth->identify();
  20.             $this->set('req', $this->request->data);
  21.             $this->set('user', $user);
  22.         }
  23.     }
  24.  
  25. // Model/Table/UsersTable.php
  26.  
  27. class UsersTable extends Table {
  28. }
  29.  
  30. // Model/Entity/User.php
  31.  
  32. class User extends Entity {
  33.     protected $_accessible = ['*' => true];
  34.    
  35.     protected function _setPassword($value) {
  36.         return (new DefaultPasswordHasher)->hash($value);
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment