php - How to use Auth in cakephp using mongodb -


i have mongo db structure users "username" , "password". trying use auth in cakephp login seems not working me. tried removing $this->data still did not work.

my password hashed using security::hash($this->data['user']['password'])

if(!empty($this->data)) {    if($this->auth->login($this->data))    {        echo "yes";    }    else{        echo "no";    } } 

in app controller have this:

public $components = array('debugkit.toolbar', 'session', 'auth' => array(     'loginaction' => array(         'controller' => 'pages',         'action' => 'home'     ),     'authenticate' => array(         'form' => array(             'fields' => array('username' => 'username', 'password' => 'password')         )     ) )); 

here result when debug login method:

array(     'user' => array(         'password' => '*****',         'username' => 'test@test.com',         'remember' => '0',         'auto_login' => '0' ) ) 

i don't know why cannot use auth mongodb. in advance.

edit:

when tried , take away layout, shows me query @ bottom of page saying:

db.users.find( {"username":"test@test.com","password":"2fdf49ffc396453960802df8fc2417655d1e8fca"}, [] ).sort( [] ).limit( 1 ).skip( 0 ) 

the hashed value of password inputted form different hash value being queried. hashed value should "a2374c309ab7823dcd9b4e21dae7511f7a9c7ec5". why cakephp converting password hash value?

there 2 ways of using $this->auth->login(). cakephp api documentation explains it:

if $user provided data stored logged in user. if $user empty or not specified, request used identify user.

the manual mentions:

in 2.0 $this->auth->login($this->request->data) log user in whatever data posted ...

so login method of users controller shouldn't pass anything:

if($this->auth->login()) {     // user logged in } 

should need manually login user can pass user data array:

if($this->auth->login($this->request->data['user'])) {     // user logged in } 

where $this->request->data['user'] like:

array(     'id' => 1,     'username' => 'admin',     'password' => '1234', ); 

note: in both cases don't need hash password done automatically.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -