<?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: Authentication &amp; Authorization with Scaffolding</title> <atom:link href="http://techlog.p2061.org/2009/04/17/authentication-authorization-with-scaffolding/feed/" rel="self" type="application/rss+xml" /><link>http://techlog.p2061.org/2009/04/17/authentication-authorization-with-scaffolding/</link> <description>Blogging from Project 2061 technology group</description> <lastBuildDate>Fri, 27 May 2011 16:37:15 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: BrianS</title><link>http://techlog.p2061.org/2009/04/17/authentication-authorization-with-scaffolding/comment-page-1/#comment-101</link> <dc:creator>BrianS</dc:creator> <pubDate>Fri, 17 Apr 2009 18:47:22 +0000</pubDate> <guid
isPermaLink="false">http://techlog.p2061.org/?p=220#comment-101</guid> <description>If you&#039;re using a version of CakePHP prior to 1.2.1.8004 you&#039;ll also need the following instructions:
Set up your users controller so that it will hash passwords (this will not be done automatically like it would if you were not using scaffolding). Add the following callback method to your users controller:
&lt;pre lang=&quot;PHP&quot;&gt;function _beforeScaffold($action) {
if (($action == &#039;edit&#039; &#124;&#124; $action == &#039;add&#039;) &amp;&amp; isset($this-&gt;data)) {
$this-&gt;data[&#039;User&#039;][&#039;password&#039;] = AuthComponent::password($this-&gt;data[&#039;User&#039;][&#039;password&#039;]);
}
return TRUE;
}&lt;/pre&gt;
The above function is called every time a scaffolded action is executed. The password hashing will only be performed if the add or edit actions are &lt;code&gt;POST&lt;/code&gt;ed.</description> <content:encoded><![CDATA[<p>If you&#8217;re using a version of CakePHP prior to 1.2.1.8004 you&#8217;ll also need the following instructions:</p><p>Set up your users controller so that it will hash passwords (this will not be done automatically like it would if you were not using scaffolding). Add the following callback method to your users controller:</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> _beforeScaffold<span style="color: #009900;">&#40;</span><span style="color: #000088;">$action</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$action</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'edit'</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$action</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'add'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'User'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> AuthComponent<span style="color: #339933;">::</span><span style="color: #004000;">password</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'User'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div><p>The above function is called every time a scaffolded action is executed. The password hashing will only be performed if the add or edit actions are <code>POST</code>ed.</p> ]]></content:encoded> </item> </channel> </rss>
