<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Simple User Registration in CakePHP 1.2, Part II</title>
	<atom:link href="http://www.littlehart.net/atthekeyboard/2008/01/22/simple-user-registration-in-cakephp-12-part-ii/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.littlehart.net/atthekeyboard/2008/01/22/simple-user-registration-in-cakephp-12-part-ii/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
	<description>Facebook should&#039;ve be written in unicornSchemaLang, because everyone *knows* that PHP is no good for anything, right?</description>
	<lastBuildDate>Mon, 15 Mar 2010 08:47:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<atom:link rel="hub" href="http://pubsubhubbub.appspot.com" />
		<item>
		<title>By: Matt Alexander</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/01/22/simple-user-registration-in-cakephp-12-part-ii/comment-page-1/#comment-11676</link>
		<dc:creator>Matt Alexander</dc:creator>
		<pubDate>Tue, 24 Mar 2009 23:00:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/2008/01/22/simple-user-registration-in-cakephp-12-part-ii/#comment-11676</guid>
		<description>I&#039;m totally splitting hairs here, but you could shorten the confirmPassword method into one line:

function confirmPassword($data) {
	return ($data[&#039;password&#039;] === Security::hash(Configure::read(&#039;Security.salt&#039;).$this-&gt;data[&#039;User&#039;][&#039;password_confirm&#039;]);
}</description>
		<content:encoded><![CDATA[<p>I&#8217;m totally splitting hairs here, but you could shorten the confirmPassword method into one line:</p>
<p>function confirmPassword($data) {<br />
	return ($data['password'] === Security::hash(Configure::read(&#8216;Security.salt&#8217;).$this-&gt;data['User']['password_confirm']);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Hartjes</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/01/22/simple-user-registration-in-cakephp-12-part-ii/comment-page-1/#comment-10853</link>
		<dc:creator>Chris Hartjes</dc:creator>
		<pubDate>Sun, 19 Oct 2008 19:03:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/2008/01/22/simple-user-registration-in-cakephp-12-part-ii/#comment-10853</guid>
		<description>@Rob

The easiest way I&#039;ve found to do that is to use James Snook&#039;s Multiple Validatable behavior http://snook.ca/archives/cakephp/multiple_validatable_behavior/

I&#039;ve used that in project where I had two different views manipulating the same data but needed different validation rules.  Hope it helps.</description>
		<content:encoded><![CDATA[<p>@Rob</p>
<p>The easiest way I&#8217;ve found to do that is to use James Snook&#8217;s Multiple Validatable behavior <a href="http://snook.ca/archives/cakephp/multiple_validatable_behavior/" rel="nofollow">http://snook.ca/archives/cakephp/multiple_validatable_behavior/</a></p>
<p>I&#8217;ve used that in project where I had two different views manipulating the same data but needed different validation rules.  Hope it helps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/01/22/simple-user-registration-in-cakephp-12-part-ii/comment-page-1/#comment-10852</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Sun, 19 Oct 2008 18:55:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/2008/01/22/simple-user-registration-in-cakephp-12-part-ii/#comment-10852</guid>
		<description>Thanks, that helps. Now I&#039;ve run into another newbie issue with the code as discussed above.

Since the password_confirm field validation says that it is required, if I create another view to update the users table, I get a validation failure on update. 

Is there a way to register the validation so that the password_confirm field is only required for the register action of the controller ?</description>
		<content:encoded><![CDATA[<p>Thanks, that helps. Now I&#8217;ve run into another newbie issue with the code as discussed above.</p>
<p>Since the password_confirm field validation says that it is required, if I create another view to update the users table, I get a validation failure on update. </p>
<p>Is there a way to register the validation so that the password_confirm field is only required for the register action of the controller ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Hartjes</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/01/22/simple-user-registration-in-cakephp-12-part-ii/comment-page-1/#comment-10851</link>
		<dc:creator>Chris Hartjes</dc:creator>
		<pubDate>Sun, 19 Oct 2008 18:48:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/2008/01/22/simple-user-registration-in-cakephp-12-part-ii/#comment-10851</guid>
		<description>@Rob

Sorry, it was a typo on my part.  What I *meant* to say was this:  if validation fails, but the password validation was okay, you replace what is in the *password* field with what was in the *password_confirm* field.  Sorry for the mixup.  I haven&#039;t tried that, but it seems to me that it should work just fine.</description>
		<content:encoded><![CDATA[<p>@Rob</p>
<p>Sorry, it was a typo on my part.  What I *meant* to say was this:  if validation fails, but the password validation was okay, you replace what is in the *password* field with what was in the *password_confirm* field.  Sorry for the mixup.  I haven&#8217;t tried that, but it seems to me that it should work just fine.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/01/22/simple-user-registration-in-cakephp-12-part-ii/comment-page-1/#comment-10850</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Sun, 19 Oct 2008 17:54:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/2008/01/22/simple-user-registration-in-cakephp-12-part-ii/#comment-10850</guid>
		<description>OK, not sure I understand that. From what I&#039;ve seen, the data gets hashed before it is saved, so I don&#039;t follow what you mean by &#039;replace the contents of the password field with what is in the password field&#039;. 

If I type in &#039;thisIsMyPassword&#039;, it gets turned into a hash. Then if the validation fails, how do I reset it to &#039;thisIsMyPassword&#039; instead of ending up hashing the hash? Or are you saying that this is a one way hash where the hash will yield the same value as the original password?

I&#039;m definitely a newbie to this framework, so I apologize for my confusion.</description>
		<content:encoded><![CDATA[<p>OK, not sure I understand that. From what I&#8217;ve seen, the data gets hashed before it is saved, so I don&#8217;t follow what you mean by &#8216;replace the contents of the password field with what is in the password field&#8217;. </p>
<p>If I type in &#8216;thisIsMyPassword&#8217;, it gets turned into a hash. Then if the validation fails, how do I reset it to &#8216;thisIsMyPassword&#8217; instead of ending up hashing the hash? Or are you saying that this is a one way hash where the hash will yield the same value as the original password?</p>
<p>I&#8217;m definitely a newbie to this framework, so I apologize for my confusion.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Hartjes</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/01/22/simple-user-registration-in-cakephp-12-part-ii/comment-page-1/#comment-10849</link>
		<dc:creator>Chris Hartjes</dc:creator>
		<pubDate>Sun, 19 Oct 2008 15:21:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/2008/01/22/simple-user-registration-in-cakephp-12-part-ii/#comment-10849</guid>
		<description>@Rob

What you&#039;re suggesting is actually very easy to fix:  if validation fails overall but the password validation passed then simply replace the contents of the password field with what is in the password field.  Not a Cake problem, a developer problem. ;)</description>
		<content:encoded><![CDATA[<p>@Rob</p>
<p>What you&#8217;re suggesting is actually very easy to fix:  if validation fails overall but the password validation passed then simply replace the contents of the password field with what is in the password field.  Not a Cake problem, a developer problem. <img src='http://www.littlehart.net/atthekeyboard/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/01/22/simple-user-registration-in-cakephp-12-part-ii/comment-page-1/#comment-10848</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Sat, 18 Oct 2008 20:06:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/2008/01/22/simple-user-registration-in-cakephp-12-part-ii/#comment-10848</guid>
		<description>I think you miss the point with not needing to reenter the password when doing validation. If I&#039;m registering for a site, and I successfully entered my password twice, but didn&#039;t pass some other validation (e.g. - fat fingered the email address), then I shouldn&#039;t need to reconfirm my password again.

The problem I&#039;ve been seeing with the Cake Auth module is that it replaces the value of the password with the hash, so that on a subsequent resubmit, the two fields will never match.

IMHO, if I have a registration form, and the form errors out for some reason besides the passwords not matching, the data in the form shouldn&#039;t get changed so that the user can address that error. Instead we end up frustrating the user by allowing them to correct the error and then failing again due to a password mismatch.</description>
		<content:encoded><![CDATA[<p>I think you miss the point with not needing to reenter the password when doing validation. If I&#8217;m registering for a site, and I successfully entered my password twice, but didn&#8217;t pass some other validation (e.g. &#8211; fat fingered the email address), then I shouldn&#8217;t need to reconfirm my password again.</p>
<p>The problem I&#8217;ve been seeing with the Cake Auth module is that it replaces the value of the password with the hash, so that on a subsequent resubmit, the two fields will never match.</p>
<p>IMHO, if I have a registration form, and the form errors out for some reason besides the passwords not matching, the data in the form shouldn&#8217;t get changed so that the user can address that error. Instead we end up frustrating the user by allowing them to correct the error and then failing again due to a password mismatch.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Gregoire</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/01/22/simple-user-registration-in-cakephp-12-part-ii/comment-page-1/#comment-10573</link>
		<dc:creator>Mike Gregoire</dc:creator>
		<pubDate>Tue, 01 Jul 2008 15:39:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/2008/01/22/simple-user-registration-in-cakephp-12-part-ii/#comment-10573</guid>
		<description>@Derek

IMO, you should NEVER reload the password. The user should always have to re-enter the password, regardless of the reason why the form was forced to reload. Password entry should never be about convenience, only about security.</description>
		<content:encoded><![CDATA[<p>@Derek</p>
<p>IMO, you should NEVER reload the password. The user should always have to re-enter the password, regardless of the reason why the form was forced to reload. Password entry should never be about convenience, only about security.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erik Gyepes</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/01/22/simple-user-registration-in-cakephp-12-part-ii/comment-page-1/#comment-10567</link>
		<dc:creator>Erik Gyepes</dc:creator>
		<pubDate>Mon, 30 Jun 2008 10:06:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/2008/01/22/simple-user-registration-in-cakephp-12-part-ii/#comment-10567</guid>
		<description>I wonder why that validation doesn&#039;t work if I define the password field first and check if it has a minLength of 6 chars and then I check the confirm_password. It doesn&#039;t display the minLength errer, however if I write it vice versa - like you above it works great. It doesn&#039;t  make much sense to me.</description>
		<content:encoded><![CDATA[<p>I wonder why that validation doesn&#8217;t work if I define the password field first and check if it has a minLength of 6 chars and then I check the confirm_password. It doesn&#8217;t display the minLength errer, however if I write it vice versa &#8211; like you above it works great. It doesn&#8217;t  make much sense to me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Derek Scruggs</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/01/22/simple-user-registration-in-cakephp-12-part-ii/comment-page-1/#comment-10021</link>
		<dc:creator>Derek Scruggs</dc:creator>
		<pubDate>Mon, 05 May 2008 22:42:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/2008/01/22/simple-user-registration-in-cakephp-12-part-ii/#comment-10021</guid>
		<description>...and I&#039;ve confirmed that it works to override save(). Here&#039;s what class User looks like. Not that I use password_match instead of password_confirm for the field name, and that the first argument to save is passed by reference.
&lt;code&gt;
function save(&amp;$data,$validate=true,$fieldlist=array()){
		if(parent::save($data,$validate,$fieldlist)){
			return true;
		}
		//if save fails, reset passwords
		$password_error = array_key_exists(&#039;password_match&#039;,$this-&gt;invalidFields()) &#124;&#124; array_key_exists(&#039;password&#039;,$this-&gt;invalidFields());
		if($password_error){
			unset($data[&#039;password&#039;]);
			unset($data[&#039;password_match&#039;]);
		} else {
			$data[&#039;password&#039;] = $_POST[&#039;data&#039;][&#039;User&#039;][&#039;password&#039;];
			$data[&#039;password_match&#039;] = $_POST[&#039;data&#039;][&#039;User&#039;][&#039;password_match&#039;];
		}
	
	}
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>&#8230;and I&#8217;ve confirmed that it works to override save(). Here&#8217;s what class User looks like. Not that I use password_match instead of password_confirm for the field name, and that the first argument to save is passed by reference.<br />
<code><br />
function save(&amp;$data,$validate=true,$fieldlist=array()){<br />
		if(parent::save($data,$validate,$fieldlist)){<br />
			return true;<br />
		}<br />
		//if save fails, reset passwords<br />
		$password_error = array_key_exists('password_match',$this-&gt;invalidFields()) || array_key_exists('password',$this-&gt;invalidFields());<br />
		if($password_error){<br />
			unset($data['password']);<br />
			unset($data['password_match']);<br />
		} else {<br />
			$data['password'] = $_POST['data']['User']['password'];<br />
			$data['password_match'] = $_POST['data']['User']['password_match'];<br />
		}</p>
<p>	}<br />
</code></p>
]]></content:encoded>
	</item>
</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->