authentication - Can't login with cakephp -


i can't login using auth in cakephp. there similar posts 1 on stackoverflow, answers seem not work me.

i have create similar register form , works auth logging in, $this->auth->login(); returns false in userscontroller.

auth uses correct usermodel , username field changed email. (note: when use username instead of email everywhere, doesn't work either). database has table user holds email , password field. password field hashed/encrypted use of: authcomponent::password()

// appcontroller

class appcontroller extends controller {      public $helpers = array('html', 'form');     public $components = array(         'session',         'auth');      public function beforefilter() {         $this->auth->usermodel = 'user';         $this->auth->fields = array('username' => 'email', 'password' => 'password');         $this->auth->loginaction = array('controller' => 'users', 'action' => 'login');         $this->auth->loginredirect = array('controller' => 'users', 'action' => 'index');     } } 

// userscontroller

class userscontroller extends appcontroller{   var $name = 'users';   var $helpers = array('html', 'form');    function beforefilter()   {            parent::beforefilter();     // tell auth not check authentication when doing 'register' action     $this->auth->allow('register');   }    function login(){       if (isset($this->data['user'])) {         $this->auth->login();         debug('tried');       }   } 

// login.ctp

<?php     echo $this->form->create('user',array('action'=>'login'));     echo $this->form->input('email');     echo $this->form->input('password');     echo $this->form->end('login');    ?> 

// user.php

<?php class user extends appmodel{      var $name = 'user'; } ?> 

i'm using cakephp few days easy error, i'm searching for few hours , have still not found it.

settings properties $this->auth->usermodel , $this->auth->fields won't in 2.x. need use $this->auth->authenticate property specify usermodel , fields options. read 2.x manual regarding auth configuration more info.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -