<?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: CakePHP &#8211; Activating User Account via Email</title>
	<atom:link href="http://www.jonnyreeves.co.uk/2008/06/cakephp-activating-user-account-via-email/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jonnyreeves.co.uk/2008/06/cakephp-activating-user-account-via-email/</link>
	<description>ActionScript Developer</description>
	<lastBuildDate>Tue, 24 Jan 2012 13:38:22 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: mohsin</title>
		<link>http://www.jonnyreeves.co.uk/2008/06/cakephp-activating-user-account-via-email/#comment-985</link>
		<dc:creator>mohsin</dc:creator>
		<pubDate>Fri, 13 May 2011 07:54:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonnyreeves.co.uk/?p=42#comment-985</guid>
		<description>thnx for script even it got some bugs but its very helpful ,,! saved my time ,,,cheers :-)</description>
		<content:encoded><![CDATA[<p>thnx for script even it got some bugs but its very helpful ,,! saved my time ,,,cheers <img src='http://www.jonnyreeves.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Slav</title>
		<link>http://www.jonnyreeves.co.uk/2008/06/cakephp-activating-user-account-via-email/#comment-984</link>
		<dc:creator>Slav</dc:creator>
		<pubDate>Mon, 10 May 2010 07:11:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonnyreeves.co.uk/?p=42#comment-984</guid>
		<description>In your activate function you&#039;ve got:
function activate($user_id = null, $in_hash = null) {
$this-&gt;User-&gt;id = $id;

This should be:

function activate($user_id = null, $in_hash = null) {
        $this-&gt;User-&gt;id = $user_id;</description>
		<content:encoded><![CDATA[<p>In your activate function you&#8217;ve got:<br />
function activate($user_id = null, $in_hash = null) {<br />
$this-&gt;User-&gt;id = $id;</p>
<p>This should be:</p>
<p>function activate($user_id = null, $in_hash = null) {<br />
        $this-&gt;User-&gt;id = $user_id;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zeusss3</title>
		<link>http://www.jonnyreeves.co.uk/2008/06/cakephp-activating-user-account-via-email/#comment-983</link>
		<dc:creator>zeusss3</dc:creator>
		<pubDate>Wed, 14 Apr 2010 10:11:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonnyreeves.co.uk/?p=42#comment-983</guid>
		<description>what do i should i install to send emails from my server using this cakephp email component.</description>
		<content:encoded><![CDATA[<p>what do i should i install to send emails from my server using this cakephp email component.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Lefkon</title>
		<link>http://www.jonnyreeves.co.uk/2008/06/cakephp-activating-user-account-via-email/#comment-982</link>
		<dc:creator>David Lefkon</dc:creator>
		<pubDate>Tue, 02 Mar 2010 08:40:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonnyreeves.co.uk/?p=42#comment-982</guid>
		<description>Nice tutorial .. thx!

Made a mod that should allow the activation code an additional day before it expires:

in app/controllers/users_controller:

function register() {
	if (!empty($this-&gt;data)) {
		$this-&gt;User-&gt;create();
		$this-&gt;User-&gt;save($this-&gt;data);
		$this-&gt;Session-&gt;setFlash(&#039;Your account has not been activated yet!&#039;);
		$this-&gt;__sendActivationEmail($this-&gt;User-&gt;getLastInsertID());
		$this-&gt;redirect(&#039;/line&#039;);
	}
}

function __sendActivationEmail($user_id) {
  $user = $this-&gt;User-&gt;find(array(&#039;User.id&#039; =&gt; $user_id), array(&#039;User.id&#039;, &#039;User.email&#039;, &#039;User.username&#039;), null, false);
  if ($user === false) {
          debug(__METHOD__.&quot; failed to retrieve User data for user.id: {$user_id}&quot;);
          return false;
  }
  // Set data for the &quot;view&quot; of the Email
  $this-&gt;set(&#039;activate_url&#039;, &#039;http://&#039; . env(&#039;SERVER_NAME&#039;) . &#039;/users/activate/&#039; . $user[&#039;User&#039;][&#039;id&#039;] . &#039;/&#039; . $this-&gt;User-&gt;getActivationHash());
  $this-&gt;set(&#039;username&#039;, $this-&gt;data[&#039;User&#039;][&#039;username&#039;]);
  $this-&gt;Email-&gt;to = $user[&#039;User&#039;][&#039;email&#039;];
  $this-&gt;Email-&gt;subject = env(&#039;SERVER_NAME&#039;) . &#039; – Please confirm your email address&#039;;
  $this-&gt;Email-&gt;from = &#039;noreply@&#039; . env(&#039;SERVER_NAME&#039;);
  $this-&gt;Email-&gt;template = &#039;user_confirm&#039;;
  $this-&gt;Email-&gt;sendAs = &#039;text&#039;;   // &#039;text&#039;, &#039;html&#039; and &#039;both&#039; are options   
  return $this-&gt;Email-&gt;send();
}
    
function activate($user_id = null, $in_hash = null) {
  $this-&gt;User-&gt;find(array(&#039;User.id&#039; =&gt; $this-&gt;params[&#039;pass&#039;][0]), array(&#039;User.id&#039;, &#039;User.email&#039;, &#039;User.username&#039;), null, false);
  if ($this-&gt;User-&gt;getActivationHash() == $this-&gt;params[&#039;pass&#039;][1] &#124;&#124; $this-&gt;User-&gt;getYesterdaysActivationHash() == $this-&gt;params[&#039;pass&#039;][1])
  {
    // Update the active flag in the database
    $this-&gt;User-&gt;saveField(&#039;active&#039;, 1);
   
    // Let the user know they can now log in!
    $this-&gt;Session-&gt;setFlash(&#039;Your account has been activated, please log in below&#039;);
    $this-&gt;redirect(&#039;login&#039;);
  }
  // Activation failed, render ‘/views/user/activate.ctp’ which should tell the user.
}


... and in app/models/user.php

function getActivationHash()
{
        if (!isset($this-&gt;id)) {
                return false;
        }
        return substr(Security::hash(Configure::read(&#039;Security.salt&#039;) . $this-&gt;field(&#039;created&#039;) . date(&#039;y&#039;) . date(&#039;m&#039;). date(&#039;d&#039;)), 0, 8);
}

function getYesterdaysActivationHash()
{
        if (!isset($this-&gt;id)) {
                return false;
        }
        return substr(Security::hash(Configure::read(&#039;Security.salt&#039;) . $this-&gt;field(&#039;created&#039;) . date(&#039;y&#039;) . date(&#039;m&#039;). date(&#039;d&#039;) - 1), 0, 8);
}</description>
		<content:encoded><![CDATA[<p>Nice tutorial .. thx!</p>
<p>Made a mod that should allow the activation code an additional day before it expires:</p>
<p>in app/controllers/users_controller:</p>
<p>function register() {<br />
	if (!empty($this-&gt;data)) {<br />
		$this-&gt;User-&gt;create();<br />
		$this-&gt;User-&gt;save($this-&gt;data);<br />
		$this-&gt;Session-&gt;setFlash(&#8216;Your account has not been activated yet!&#8217;);<br />
		$this-&gt;__sendActivationEmail($this-&gt;User-&gt;getLastInsertID());<br />
		$this-&gt;redirect(&#8216;/line&#8217;);<br />
	}<br />
}</p>
<p>function __sendActivationEmail($user_id) {<br />
  $user = $this-&gt;User-&gt;find(array(&#8216;User.id&#8217; =&gt; $user_id), array(&#8216;User.id&#8217;, &#8216;User.email&#8217;, &#8216;User.username&#8217;), null, false);<br />
  if ($user === false) {<br />
          debug(__METHOD__.&#8221; failed to retrieve User data for user.id: {$user_id}&#8221;);<br />
          return false;<br />
  }<br />
  // Set data for the &#8220;view&#8221; of the Email<br />
  $this-&gt;set(&#8216;activate_url&#8217;, &#8216;http://&#8217; . env(&#8216;SERVER_NAME&#8217;) . &#8216;/users/activate/&#8217; . $user['User']['id'] . &#8216;/&#8217; . $this-&gt;User-&gt;getActivationHash());<br />
  $this-&gt;set(&#8216;username&#8217;, $this-&gt;data['User']['username']);<br />
  $this-&gt;Email-&gt;to = $user['User']['email'];<br />
  $this-&gt;Email-&gt;subject = env(&#8216;SERVER_NAME&#8217;) . &#8216; – Please confirm your email address&#8217;;<br />
  $this-&gt;Email-&gt;from = &#8216;noreply@&#8217; . env(&#8216;SERVER_NAME&#8217;);<br />
  $this-&gt;Email-&gt;template = &#8216;user_confirm&#8217;;<br />
  $this-&gt;Email-&gt;sendAs = &#8216;text&#8217;;   // &#8216;text&#8217;, &#8216;html&#8217; and &#8216;both&#8217; are options<br />
  return $this-&gt;Email-&gt;send();<br />
}</p>
<p>function activate($user_id = null, $in_hash = null) {<br />
  $this-&gt;User-&gt;find(array(&#8216;User.id&#8217; =&gt; $this-&gt;params['pass'][0]), array(&#8216;User.id&#8217;, &#8216;User.email&#8217;, &#8216;User.username&#8217;), null, false);<br />
  if ($this-&gt;User-&gt;getActivationHash() == $this-&gt;params['pass'][1] || $this-&gt;User-&gt;getYesterdaysActivationHash() == $this-&gt;params['pass'][1])<br />
  {<br />
    // Update the active flag in the database<br />
    $this-&gt;User-&gt;saveField(&#8216;active&#8217;, 1);</p>
<p>    // Let the user know they can now log in!<br />
    $this-&gt;Session-&gt;setFlash(&#8216;Your account has been activated, please log in below&#8217;);<br />
    $this-&gt;redirect(&#8216;login&#8217;);<br />
  }<br />
  // Activation failed, render ‘/views/user/activate.ctp’ which should tell the user.<br />
}</p>
<p>&#8230; and in app/models/user.php</p>
<p>function getActivationHash()<br />
{<br />
        if (!isset($this-&gt;id)) {<br />
                return false;<br />
        }<br />
        return substr(Security::hash(Configure::read(&#8216;Security.salt&#8217;) . $this-&gt;field(&#8216;created&#8217;) . date(&#8216;y&#8217;) . date(&#8216;m&#8217;). date(&#8216;d&#8217;)), 0, 8);<br />
}</p>
<p>function getYesterdaysActivationHash()<br />
{<br />
        if (!isset($this-&gt;id)) {<br />
                return false;<br />
        }<br />
        return substr(Security::hash(Configure::read(&#8216;Security.salt&#8217;) . $this-&gt;field(&#8216;created&#8217;) . date(&#8216;y&#8217;) . date(&#8216;m&#8217;). date(&#8216;d&#8217;) &#8211; 1), 0, 8);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ganzgenau</title>
		<link>http://www.jonnyreeves.co.uk/2008/06/cakephp-activating-user-account-via-email/#comment-981</link>
		<dc:creator>Ganzgenau</dc:creator>
		<pubDate>Mon, 21 Dec 2009 16:45:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonnyreeves.co.uk/?p=42#comment-981</guid>
		<description>Thanks so much!</description>
		<content:encoded><![CDATA[<p>Thanks so much!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ANAND</title>
		<link>http://www.jonnyreeves.co.uk/2008/06/cakephp-activating-user-account-via-email/#comment-980</link>
		<dc:creator>ANAND</dc:creator>
		<pubDate>Tue, 24 Nov 2009 06:59:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonnyreeves.co.uk/?p=42#comment-980</guid>
		<description>hi all...
Actually am getting bellow mentioned error

Missing Component File

Error: The component file was not found.

Error: Create the class ‘Auth’Component in file: appcontrollerscomponents‘auth’.php



Notice: If you want to customize this error message, create appviewserrorsmissing_component_file.ctp



not getting wt is the proble...</description>
		<content:encoded><![CDATA[<p>hi all&#8230;<br />
Actually am getting bellow mentioned error</p>
<p>Missing Component File</p>
<p>Error: The component file was not found.</p>
<p>Error: Create the class ‘Auth’Component in file: appcontrollerscomponents‘auth’.php</p>
<p>Notice: If you want to customize this error message, create appviewserrorsmissing_component_file.ctp</p>
<p>not getting wt is the proble&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Siddhartha</title>
		<link>http://www.jonnyreeves.co.uk/2008/06/cakephp-activating-user-account-via-email/#comment-979</link>
		<dc:creator>Siddhartha</dc:creator>
		<pubDate>Tue, 17 Nov 2009 02:39:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonnyreeves.co.uk/?p=42#comment-979</guid>
		<description>Wonderful tutorial.
Just one point to note.

file:// /app/controllers/users_controller.php

Add following line in the UsersController::beforeFilter()
{
...
$this-&gt;Auth-&gt;autoRedirect = false;
...
}
This will allow you to use further checking on login() action.</description>
		<content:encoded><![CDATA[<p>Wonderful tutorial.<br />
Just one point to note.</p>
<p>file:// /app/controllers/users_controller.php</p>
<p>Add following line in the UsersController::beforeFilter()<br />
{<br />
&#8230;<br />
$this-&gt;Auth-&gt;autoRedirect = false;<br />
&#8230;<br />
}<br />
This will allow you to use further checking on login() action.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Glen Barnhardt</title>
		<link>http://www.jonnyreeves.co.uk/2008/06/cakephp-activating-user-account-via-email/#comment-978</link>
		<dc:creator>Glen Barnhardt</dc:creator>
		<pubDate>Fri, 31 Jul 2009 18:47:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonnyreeves.co.uk/?p=42#comment-978</guid>
		<description>Thanks for the great article. I was able to implement this into my latest application with not to much work. Thanks for all the great comments as they helped me to fix the few errors I ran into during the implementation.

Good Job!!</description>
		<content:encoded><![CDATA[<p>Thanks for the great article. I was able to implement this into my latest application with not to much work. Thanks for all the great comments as they helped me to fix the few errors I ran into during the implementation.</p>
<p>Good Job!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Diogenes (youngwebmaster)</title>
		<link>http://www.jonnyreeves.co.uk/2008/06/cakephp-activating-user-account-via-email/#comment-977</link>
		<dc:creator>Diogenes (youngwebmaster)</dc:creator>
		<pubDate>Tue, 07 Jul 2009 15:11:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonnyreeves.co.uk/?p=42#comment-977</guid>
		<description>@Steppio, @bryan, @Jonny
The problem is the fact that there is a small oversight/typo in the code. 

function activate($user_id = null, $in_hash = null) {
        $this-&gt;User-&gt;id = $id;

should actually be

function activate($user_id = null, $in_hash = null) {
        $this-&gt;User-&gt;id = $user_id;

He referred to $id instead of $user_id, which was the real name of the variable passed to the function via the url, which is why this wouldn&#039;t work/would give you errors if you just copied and pasted the above code. Just goes to show that using someone&#039;s code without really knowing what it&#039;s doing and how is a bad idea.

Cheers!</description>
		<content:encoded><![CDATA[<p>@Steppio, @bryan, @Jonny<br />
The problem is the fact that there is a small oversight/typo in the code. </p>
<p>function activate($user_id = null, $in_hash = null) {<br />
        $this-&gt;User-&gt;id = $id;</p>
<p>should actually be</p>
<p>function activate($user_id = null, $in_hash = null) {<br />
        $this-&gt;User-&gt;id = $user_id;</p>
<p>He referred to $id instead of $user_id, which was the real name of the variable passed to the function via the url, which is why this wouldn&#8217;t work/would give you errors if you just copied and pasted the above code. Just goes to show that using someone&#8217;s code without really knowing what it&#8217;s doing and how is a bad idea.</p>
<p>Cheers!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bryan</title>
		<link>http://www.jonnyreeves.co.uk/2008/06/cakephp-activating-user-account-via-email/#comment-976</link>
		<dc:creator>bryan</dc:creator>
		<pubDate>Wed, 10 Jun 2009 03:11:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonnyreeves.co.uk/?p=42#comment-976</guid>
		<description>This article is exactly what I was looking for but I am experiencing a lot of trouble adjusting the code to work with Cake 1.2 - I am new to Cake. Is there a chance someone can clarify what to do for things such as:

__sendActivationEmail(...)
 $user[&#039;User&#039;][&#039;id&#039;]
giving me Undefined index:  id

function activate(...)
 $this-&gt;User-&gt;id = $id;
giving me Undefined variable: id

Any chance someone can port this??

I hope this isn&#039;t a stupid question - Sorry in advance if it is!</description>
		<content:encoded><![CDATA[<p>This article is exactly what I was looking for but I am experiencing a lot of trouble adjusting the code to work with Cake 1.2 &#8211; I am new to Cake. Is there a chance someone can clarify what to do for things such as:</p>
<p>__sendActivationEmail(&#8230;)<br />
 $user['User']['id']<br />
giving me Undefined index:  id</p>
<p>function activate(&#8230;)<br />
 $this-&gt;User-&gt;id = $id;<br />
giving me Undefined variable: id</p>
<p>Any chance someone can port this??</p>
<p>I hope this isn&#8217;t a stupid question &#8211; Sorry in advance if it is!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

