authentication - CakePHP Auth Component Blanks out Password -
i have following code login view:
<?php echo $session->flash('auth'); echo $this->form->create('user', array('action' => 'login')); echo $this->form->input('email'); echo $this->form->input('password'); echo $this->form->end('login'); ?>
this generates following html:
<div id="authmessage" class="message">login failed. invalid username or password.</div> <form id="userloginform" method="post" action="/control/users/login" accept-charset="utf-8"> <div style="display: none;"><input name="_method" value="post" type="hidden"></div> <div class="input text required"> <label for="useremail">email</label> <input name="data[user][email]" maxlength="255" value="" id="useremail" type="text"> </div> <div class="input password"> <label for="userpassword">password</label> <input name="data[user][password]" id="userpassword" type="password"> </div> <div class="submit"><input value="login" type="submit"></div> </form>
app controller:
function beforefilter() { $this->auth->fields = array ( 'username' => 'email', 'password' => 'password' ); }
when attempt log in error password incorrect. here's dump of $this->data:
array ( [user] => array ( [email] => myemail@gmail.com [password] => ) )
i found few other similar questions on stackoverflow none of them seem have answer. know why happening?
the cakephp auth component hash password , try match password in db.
hashing password salt.
if sethash md5 then
md5($password.$salt)
stored matched password in db.
so plz make sure storing password correct.
to enter dummy data. try debug $this->auth->password($password)
copy result , insert in db.
if password wrong auth component reset password field internally.ie., why u result.
array ( [user] => array ( [email] => myemail@gmail.com [password] => ) )
this doesn't means password not available checking db.
happy baking
Comments
Post a Comment