php - CakePHP 2.x first login with hash password no users in DB -
i have check , when create users , passwords , try login , successful, if example install on other device project , set db enter system how can access first time if dont have users created?
1) tried create user , password on database cant recognize password due hashing methods.
how can access first time , create users normal?
my login access controller:
public function login() { //if logged-in, redirect if($this->session->check('auth.user')){ $this->redirect(array('action' => 'index')); } // if post information, try authenticate if ($this->request->is('post')) { if ($this->auth->login()) { $this->session->setflash(__('bienvenido, '. $this->auth->user('username'))); $this->redirect($this->auth->redirecturl()); } else { $this->session->setflash(__('usuario o password invalidos')); } } $this->layout = 'login'; } appcontroller:
class appcontroller extends controller { //public $components = array('debugkit.toolbar'); public $components = array( //'debugkit.toolbar', 'session', 'auth' => array( 'authorize' => 'controller', 'actionpath' => 'controllers/', 'loginredirect' => array('controller' => 'users', 'action' => 'index'), 'logoutredirect' => array('controller' => 'users', 'action' => 'login'), 'autherror' => 'you must logged in view page.', 'loginerror' => 'invalid username or password entered, please try again.' ), ); // allow login controllers public function beforefilter() { $this->auth->allow('login','view','index','logout','getdata'); } public function isauthorized($user) { // here should verify role , give access based on role if (isset($user['role']) && $user['role'] === 'adm') { return true; } if (in_array($this->action, array('add','getdata','getdataarticulos','adddetfac','descargar','getnit'))) { if (isset($user['role']) && $user['role'] === 'vend') return true; else return $this->session->setflash(__('acceso denegado.'), 'error'); } return $this->session->setflash(__('acceso denegado.'), 'error'); } }
at first allow add method.
public function beforefilter() { $this->auth->allow('login','view','index','logout','getdata','add'); } then create user, write in browser url your_project_path/users/add
after add 1st user remove add auth allow.
Comments
Post a Comment