Added: 1 year ago
From: andrewperk
Views: 6,750
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (12)

Sign In or Sign Up now to post a comment!
  • well I found out why my code was failing. I didn't have my hashPasswords method return TRUE :-P

    Thanks for your help though!

  • Question ..... in hashPassword method, if the driver uses the Auth compoent and POST data is received by containing the fields, automatically performs the hash the password field using this function.

  • Why the heck would you want a maximum length for a password?

    It gets hashed so in the database it always ends up as a fixed size anyway.

  • @ivolol Because allowing a user to create a password that is really long makes it harder for them to remember.

  • Dear Andrew, very nice tutorial as always... thank you so much.

    Just one question about the hashPasswords() function: You overwrite the function with only one parameter $data. But, you call it with two parameters (NULL, TRUE). Can you tell me why is it like this?

    Also, please do a tutorial to use the Ajax component soon. Thanks, again.

  • @abcd321839955 I have the same doubt that you. Can anyone help us???

  • @abcd321839955 It's been a while but from what I remember when over writing the hashPasswords method for some reason if I don't pass true in as a second argument when calling this method it will not hash the password or will not save it. I can't remember which one. I figured this out from googling around. I looked at the api for the hashPasswords method and it doesn't seem to have a second parameter. Try it out, try not passing true in as a second param. It wont work properly.

  • @andrewperk why are we passing in $data to the hashPasswords function then using $this->data inside the condition. You never convert $data to $this->data then you return $data again, so won't you just return exactly what you pass in?

  • @ryantuosto The $data that is passed in is a different data array than the $this->data array. The reason we rewrote the hashPasswords method was so that we could properly validate the password ourselves rather than it coming in automatically hashed. By checking the $this->data passwords we can compare them before the hash. Then we manually hash them, returning the passed in $data array which is the same as what we just hashed anyways we just did it manually so we can compare them.

  • @andrewperk I appreciate the replies, can you explain the difference between $data and $this->$data ?

  • @ryantuosto Not gonna lie, I'm not entirely sure the exact differences. All I know is that if I rewrite the hashPasswords method using $data it will not work because password will never match password_confirmation because password $data['User']['password'] comes into the $data array already hashed. Where as $this->data pulls directly from the form I believe, thus $this->data['User']['password'­] is the plain password.

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more