Powered by Invision Power Board



  Reply to this topicStart new topicStart Poll

> validating login data fails because of md5
tom.fox
Posted: Jun 19 2010, 09:39 PM
Quote Post


Newbie
*

Group: Members
Posts: 3
Member No.: 2124
Joined: 19-June 10



hi,

i have a problem. i am saving the users password at registration as md5.
when the user is trying a login, i check if the entered username and password is equal to the entry in the database. for that, i have to convert the entered password into md5, to make it comparable:

thats the code to find the user in my controller class

CODE

$user = $this->User->find(array('email' => $this->data['User']['email'], 'password' => md5($this->data['User']['password'])), array('id', 'email'));
           if(empty($user) == false)


now if print the query to check what it looks like, one thing is odd. no matter what password i enter it is ALWAYS(!) the same md5 key:

CODE

SELECT `User`.`id`, `User`.`email` FROM `users` AS `User` WHERE `email` = 'test@web.de' AND `password` = 'd41d8cd98f00b204e9800998ecf8427e' LIMIT 1


no wonder i get no results and the variable "$user" is empty...i get "d41d8cd98f00b204e9800998ecf8427e" everytime..

thats a mystery....does somebody know the answer? i'd be soooo happy

many many thanks

btw: thats my view

CODE

<div class="">
<h2>Login</h2>    
   <?php echo $form->create('User', array('action' => 'login'));?>
       <?php echo $form->input('email');?>
       <?php echo $form->input('password');?>
       <?php echo $form->submit('Login');?>
   <?php echo $form->end(); ?>
</div>
PMEmail Poster
Top
_dExter
Posted: Jan 28 2011, 11:45 PM
Quote Post


Newbie
*

Group: Members
Posts: 2
Member No.: 2639
Joined: 28-January 11



I think I have the same problem... Anyone knows any solution?
PMEmail Poster
Top
endyourif
Posted: Jan 30 2011, 01:18 AM
Quote Post


Member
**

Group: Members
Posts: 14
Member No.: 2552
Joined: 2-January 11



The md5 value being display is for an empty string.

I would begin by debugging your $this->data because it sounds like it is not being set properly.

Another question, why not just use the Auth component to do this? You can follow my simple tutorial here to set it up in less than 10 minutes: CakePHP Login System


--------------------
Endyourif.com - Helping you solve those tough coding problems
PMEmail Poster
Top
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll

 

Disclaimer:
This forum is in no way affiliated with the Cake Software Foundation
The CakePHP name and icon is a trademark of the Cake Software Foundation


Lo-Fi Version