<?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: How to use the OpenID component with the Auth component</title>
	<atom:link href="http://cakebaker.42dh.com/2008/12/09/how-to-use-the-openid-component-with-the-auth-component/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com/2008/12/09/how-to-use-the-openid-component-with-the-auth-component/</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Thu, 11 Mar 2010 15:41:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Nate Hanna</title>
		<link>http://cakebaker.42dh.com/2008/12/09/how-to-use-the-openid-component-with-the-auth-component/comment-page-1/#comment-144502</link>
		<dc:creator>Nate Hanna</dc:creator>
		<pubDate>Mon, 25 Jan 2010 03:56:38 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=994#comment-144502</guid>
		<description>@cakebaker ... I was able to get it figured out today (a work around for the hardcoded &quot;Continue&quot;). I&#039;ll try to post a solution within the next few days. I would do it now but it has been a long day; time to rest!</description>
		<content:encoded><![CDATA[<p>@cakebaker &#8230; I was able to get it figured out today (a work around for the hardcoded &#8220;Continue&#8221;). I&#8217;ll try to post a solution within the next few days. I would do it now but it has been a long day; time to rest!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nate Hanna</title>
		<link>http://cakebaker.42dh.com/2008/12/09/how-to-use-the-openid-component-with-the-auth-component/comment-page-1/#comment-144353</link>
		<dc:creator>Nate Hanna</dc:creator>
		<pubDate>Fri, 22 Jan 2010 17:45:53 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=994#comment-144353</guid>
		<description>@cakebaker ... that&#039;s what I thought. I&#039;ll take a look over the next few days to see if I can make it more flexible. If I cannot I know two other well rehearsed CakePHP developers (more than I am) that can probably point us in the right direction.</description>
		<content:encoded><![CDATA[<p>@cakebaker &#8230; that&#8217;s what I thought. I&#8217;ll take a look over the next few days to see if I can make it more flexible. If I cannot I know two other well rehearsed CakePHP developers (more than I am) that can probably point us in the right direction.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/12/09/how-to-use-the-openid-component-with-the-auth-component/comment-page-1/#comment-144345</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Fri, 22 Jan 2010 15:50:52 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=994#comment-144345</guid>
		<description>@Nate: It is hard coded in the current version :&#124;  However, it would make sense for a more flexible approach, though I don&#039;t know yet what the best approach is to implement this feature.</description>
		<content:encoded><![CDATA[<p>@Nate: It is hard coded in the current version :|  However, it would make sense for a more flexible approach, though I don&#8217;t know yet what the best approach is to implement this feature.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nate Hanna</title>
		<link>http://cakebaker.42dh.com/2008/12/09/how-to-use-the-openid-component-with-the-auth-component/comment-page-1/#comment-144270</link>
		<dc:creator>Nate Hanna</dc:creator>
		<pubDate>Thu, 21 Jan 2010 19:03:38 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=994#comment-144270</guid>
		<description>I&#039;ve was finally able to get the bugs worked out of &quot;Peter’s comment for a possible solution for the current CakePHP release (1.2.5.x)&quot; on my development app where I am integrating OpenID as an alternative to traditional Authentication. I will share my code in a post on my blog/as a new comment here later. I have one issue however that I cannot seem to figure out. When there is a delay/failure with OpenID it renders a &quot;Continue&quot; button without any layout; is there a way to fix this to be within the site&#039;s layout structure?</description>
		<content:encoded><![CDATA[<p>I&#8217;ve was finally able to get the bugs worked out of &#8220;Peter’s comment for a possible solution for the current CakePHP release (1.2.5.x)&#8221; on my development app where I am integrating OpenID as an alternative to traditional Authentication. I will share my code in a post on my blog/as a new comment here later. I have one issue however that I cannot seem to figure out. When there is a delay/failure with OpenID it renders a &#8220;Continue&#8221; button without any layout; is there a way to fix this to be within the site&#8217;s layout structure?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/12/09/how-to-use-the-openid-component-with-the-auth-component/comment-page-1/#comment-137775</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Thu, 08 Oct 2009 14:48:24 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=994#comment-137775</guid>
		<description>@Robin: You are welcome!</description>
		<content:encoded><![CDATA[<p>@Robin: You are welcome!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robin</title>
		<link>http://cakebaker.42dh.com/2008/12/09/how-to-use-the-openid-component-with-the-auth-component/comment-page-1/#comment-137696</link>
		<dc:creator>Robin</dc:creator>
		<pubDate>Tue, 06 Oct 2009 23:29:39 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=994#comment-137696</guid>
		<description>Thanks go to cakebaker and Peter to getting this working. Good work guys.</description>
		<content:encoded><![CDATA[<p>Thanks go to cakebaker and Peter to getting this working. Good work guys.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/12/09/how-to-use-the-openid-component-with-the-auth-component/comment-page-1/#comment-133920</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Sun, 02 Aug 2009 14:53:46 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=994#comment-133920</guid>
		<description>@Peter: Thanks for sharing this code, though here I wasn&#039;t able to make it work so far...</description>
		<content:encoded><![CDATA[<p>@Peter: Thanks for sharing this code, though here I wasn&#8217;t able to make it work so far&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Robinett</title>
		<link>http://cakebaker.42dh.com/2008/12/09/how-to-use-the-openid-component-with-the-auth-component/comment-page-1/#comment-133898</link>
		<dc:creator>Peter Robinett</dc:creator>
		<pubDate>Sun, 02 Aug 2009 05:40:11 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=994#comment-133898</guid>
		<description>With a little tweaking I got the code to work. In the latest stable version of Cake. Thanks so much for the component!

The relevant code:
&lt;code&gt;
// app/views/user/login.ctp
flash(&#039;auth&#039;);

echo $form-&gt;create(&#039;User&#039;, array(&#039;action&#039; =&gt; &#039;login&#039;));
echo $form-&gt;input(&#039;username&#039;, array(&#039;label&#039; =&gt; &#039;OpenID:&#039;));
echo $form-&gt;input(&#039;password&#039;, array(&#039;type&#039; =&gt; &#039;hidden&#039;));
echo $form-&gt;end(&#039;Login&#039;);
&lt;/code&gt;
&lt;code&gt;
// app/model/user.php
public function find($conditions = null, $fields = array(), $order = null, $recursive = null) {	
    if (is_array($conditions) &amp;&amp; isset($conditions[&#039;User.username&#039;])) {
        $newconditions = array(&#039;User.openid&#039; =&gt; $conditions[&#039;User.username&#039;]);
        return parent::find($newconditions, $fields, $order, $recursive);
    }
    return parent::find($conditions, $fields, $order, $recursive);
}
&lt;/code&gt;
&lt;code&gt;
// app/controllers/users_controller.php
private function handleOpenIDResponse($returnTo) {
    /* the OpenID response */
    $response = $this-&gt;Openid-&gt;getResponse($returnTo);        
    if ($response-&gt;status == Auth_OpenID_CANCEL) {
        $this-&gt;setMessage(&#039;Verification cancelled&#039;);
    } elseif ($response-&gt;status == Auth_OpenID_FAILURE) {
        $this-&gt;setMessage(&#039;OpenID verification failed: &#039;.$response-&gt;message);
    } elseif ($response-&gt;status == Auth_OpenID_SUCCESS) {
        $openid = $response-&gt;identity_url;
        // ugly hack to remove trailing slash, since Auth component strips it and we need to match
        if (substr($openid, -1) == &#039;/&#039;)
        {
            $openid = substr($openid, 0, -1);
        }
        $data = array(&#039;User&#039; =&gt; array(&#039;openid&#039; =&gt; $openid));

        /* here create the User if it doesn&#039;t already exist */
        $user = $this-&gt;User-&gt;find(&#039;first&#039;, array(&#039;conditions&#039; =&gt; array(&#039;User.openid&#039; =&gt; $openid)));
        /* create user if it doesn&#039;t already exist */
        if ($user === false)
        {
            $this-&gt;User-&gt;create();
        }
        
        /* array of any user details we requested, if the user returned them */
        $sregResponse = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
        $sreg = $sregResponse-&gt;contents();
        if ($sreg)
        {
            if(array_key_exists(&#039;fullname&#039;, $sreg))
            {
                $data[&#039;User&#039;][&#039;name&#039;] = $sreg[&#039;fullname&#039;];
            }
            if(array_key_exists(&#039;email&#039;, $sreg))
            {
                $data[&#039;User&#039;][&#039;email&#039;] = $sreg[&#039;email&#039;];
            }
        }
        /* save user details */
        $success = $this-&gt;User-&gt;save($data);
        
        $loggedin = $this-&gt;Auth-&gt;login($response);
        $this-&gt;redirect($this-&gt;Auth-&gt;redirect());
    }
}
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>With a little tweaking I got the code to work. In the latest stable version of Cake. Thanks so much for the component!</p>
<p>The relevant code:<br />
<pre><code>// app/views/user/login.ctp
flash('auth');

echo $form-&gt;create('User', array('action' =&gt; 'login'));
echo $form-&gt;input('username', array('label' =&gt; 'OpenID:'));
echo $form-&gt;input('password', array('type' =&gt; 'hidden'));
echo $form-&gt;end('Login');</code></pre><br />
<pre><code>// app/model/user.php
public function find($conditions = null, $fields = array(), $order = null, $recursive = null) {	
    if (is_array($conditions) &amp;&amp; isset($conditions['User.username'])) {
        $newconditions = array('User.openid' =&gt; $conditions['User.username']);
        return parent::find($newconditions, $fields, $order, $recursive);
    }
    return parent::find($conditions, $fields, $order, $recursive);
}</code></pre><br />
<pre><code>// app/controllers/users_controller.php
private function handleOpenIDResponse($returnTo) {
    /* the OpenID response */
    $response = $this-&gt;Openid-&gt;getResponse($returnTo);        
    if ($response-&gt;status == Auth_OpenID_CANCEL) {
        $this-&gt;setMessage('Verification cancelled');
    } elseif ($response-&gt;status == Auth_OpenID_FAILURE) {
        $this-&gt;setMessage('OpenID verification failed: '.$response-&gt;message);
    } elseif ($response-&gt;status == Auth_OpenID_SUCCESS) {
        $openid = $response-&gt;identity_url;
        // ugly hack to remove trailing slash, since Auth component strips it and we need to match
        if (substr($openid, -1) == '/')
        {
            $openid = substr($openid, 0, -1);
        }
        $data = array('User' =&gt; array('openid' =&gt; $openid));

        /* here create the User if it doesn't already exist */
        $user = $this-&gt;User-&gt;find('first', array('conditions' =&gt; array('User.openid' =&gt; $openid)));
        /* create user if it doesn't already exist */
        if ($user === false)
        {
            $this-&gt;User-&gt;create();
        }
        
        /* array of any user details we requested, if the user returned them */
        $sregResponse = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
        $sreg = $sregResponse-&gt;contents();
        if ($sreg)
        {
            if(array_key_exists('fullname', $sreg))
            {
                $data['User']['name'] = $sreg['fullname'];
            }
            if(array_key_exists('email', $sreg))
            {
                $data['User']['email'] = $sreg['email'];
            }
        }
        /* save user details */
        $success = $this-&gt;User-&gt;save($data);
        
        $loggedin = $this-&gt;Auth-&gt;login($response);
        $this-&gt;redirect($this-&gt;Auth-&gt;redirect());
    }
}</code></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: lboynton</title>
		<link>http://cakebaker.42dh.com/2008/12/09/how-to-use-the-openid-component-with-the-auth-component/comment-page-1/#comment-133439</link>
		<dc:creator>lboynton</dc:creator>
		<pubDate>Sat, 25 Jul 2009 09:38:13 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=994#comment-133439</guid>
		<description>I haven&#039;t found a workaround either as yet. Oh yeah, I am lboy by the way, I forgot I posted on here before!</description>
		<content:encoded><![CDATA[<p>I haven&#8217;t found a workaround either as yet. Oh yeah, I am lboy by the way, I forgot I posted on here before!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/12/09/how-to-use-the-openid-component-with-the-auth-component/comment-page-1/#comment-133365</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Fri, 24 Jul 2009 09:17:12 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=994#comment-133365</guid>
		<description>@lboynton: Thanks for your comment!

Yes, you are right, this approach no longer works. I tried to find a workaround, but without luck so far...</description>
		<content:encoded><![CDATA[<p>@lboynton: Thanks for your comment!</p>
<p>Yes, you are right, this approach no longer works. I tried to find a workaround, but without luck so far&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
