<?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/"
	xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Getting Auth and Admin Routing to play nicely together</title>
	<atom:link href="http://teknoid.wordpress.com/2009/01/12/462/feed/" rel="self" type="application/rss+xml" />
	<link>http://teknoid.wordpress.com/2009/01/12/462/</link>
	<description></description>
	<lastBuildDate>Wed, 11 Nov 2009 14:36:41 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: teknoid</title>
		<link>http://teknoid.wordpress.com/2009/01/12/462/#comment-2395</link>
		<dc:creator>teknoid</dc:creator>
		<pubDate>Sat, 24 Oct 2009 22:53:48 +0000</pubDate>
		<guid isPermaLink="false">http://teknoid.wordpress.com/?p=462#comment-2395</guid>
		<description>@Cody

Great addition. Thanks for sharing.

p.s. I&#039;ve made corrections per your request.</description>
		<content:encoded><![CDATA[<p>@Cody</p>
<p>Great addition. Thanks for sharing.</p>
<p>p.s. I&#8217;ve made corrections per your request.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cody</title>
		<link>http://teknoid.wordpress.com/2009/01/12/462/#comment-2394</link>
		<dc:creator>Cody</dc:creator>
		<pubDate>Sat, 24 Oct 2009 20:09:14 +0000</pubDate>
		<guid isPermaLink="false">http://teknoid.wordpress.com/?p=462#comment-2394</guid>
		<description>First of all, thanks for the article, very simple concept and I really like it :).

Just a quick tip for anyone out there who require your user authentication as well as admin and want to deny access to any user trying to use any admin prefixed link.  

1) You need to create a field in your users table called &#039;role&#039;.  Then either make a user an &#039;admin&#039; or &#039;user&#039; (Or use whatever you prefer.).

2) In your AppController::beforeFilter() add this bit of code at the bottom

$admin = Configure::read(&#039;Routing.admin&#039;);
if (isset($this-&gt;params[$admin]) &amp;&amp; $this-&gt;params[$admin] &amp;&amp; $this-&gt;Auth-&gt;user(&#039;role&#039;) != &#039;admin&#039;) 
        {
            $this-&gt;Session-&gt;setFlash(&#039;You are not authorized.&#039;, &#039;default&#039;, array(&#039;class&#039; =&gt; &#039;error&#039;));
            $this-&gt;redirect(&#039;/&#039;);
        }

Basically what this does is check to see if the users role is admin and redirects to the home page if they are not.  For added security remove the flash message and redirect and serve up a 404 error so the user doesn’t know they found an admin link.</description>
		<content:encoded><![CDATA[<p>First of all, thanks for the article, very simple concept and I really like it :).</p>
<p>Just a quick tip for anyone out there who require your user authentication as well as admin and want to deny access to any user trying to use any admin prefixed link.  </p>
<p>1) You need to create a field in your users table called &#8216;role&#8217;.  Then either make a user an &#8216;admin&#8217; or &#8216;user&#8217; (Or use whatever you prefer.).</p>
<p>2) In your AppController::beforeFilter() add this bit of code at the bottom</p>
<p>$admin = Configure::read(&#8216;Routing.admin&#8217;);<br />
if (isset($this-&gt;params[$admin]) &amp;&amp; $this-&gt;params[$admin] &amp;&amp; $this-&gt;Auth-&gt;user(&#8216;role&#8217;) != &#8216;admin&#8217;)<br />
        {<br />
            $this-&gt;Session-&gt;setFlash(&#8216;You are not authorized.&#8217;, &#8216;default&#8217;, array(&#8216;class&#8217; =&gt; &#8216;error&#8217;));<br />
            $this-&gt;redirect(&#8216;/&#8217;);<br />
        }</p>
<p>Basically what this does is check to see if the users role is admin and redirects to the home page if they are not.  For added security remove the flash message and redirect and serve up a 404 error so the user doesn’t know they found an admin link.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://teknoid.wordpress.com/2009/01/12/462/#comment-2133</link>
		<dc:creator>David</dc:creator>
		<pubDate>Tue, 25 Aug 2009 08:08:50 +0000</pubDate>
		<guid isPermaLink="false">http://teknoid.wordpress.com/?p=462#comment-2133</guid>
		<description>I&#039;d like to add my thanks for this great article.

I had hoped to construct my app. so that I had one login form /users/login/ and then to use logic in the login action to decide if the user was an administrator and redirect them to /admin/users/whatever/. 

Is there a way to do this? All my attempts came to nought so for now I&#039;ve used your method of having a separate admin login /admin/users/login/</description>
		<content:encoded><![CDATA[<p>I&#8217;d like to add my thanks for this great article.</p>
<p>I had hoped to construct my app. so that I had one login form /users/login/ and then to use logic in the login action to decide if the user was an administrator and redirect them to /admin/users/whatever/. </p>
<p>Is there a way to do this? All my attempts came to nought so for now I&#8217;ve used your method of having a separate admin login /admin/users/login/</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: teknoid</title>
		<link>http://teknoid.wordpress.com/2009/01/12/462/#comment-1874</link>
		<dc:creator>teknoid</dc:creator>
		<pubDate>Fri, 26 Jun 2009 13:14:17 +0000</pubDate>
		<guid isPermaLink="false">http://teknoid.wordpress.com/?p=462#comment-1874</guid>
		<description>@Gediminas

Everything is disallowed by default.</description>
		<content:encoded><![CDATA[<p>@Gediminas</p>
<p>Everything is disallowed by default.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gediminas</title>
		<link>http://teknoid.wordpress.com/2009/01/12/462/#comment-1871</link>
		<dc:creator>Gediminas</dc:creator>
		<pubDate>Fri, 26 Jun 2009 09:16:54 +0000</pubDate>
		<guid isPermaLink="false">http://teknoid.wordpress.com/?p=462#comment-1871</guid>
		<description>It`s old school:
$this-&gt;Auth-&gt;allow(&#039;index&#039;, &#039;view&#039;);

can we dissallow /admin/ prefix automatically?</description>
		<content:encoded><![CDATA[<p>It`s old school:<br />
$this-&gt;Auth-&gt;allow(&#8216;index&#8217;, &#8216;view&#8217;);</p>
<p>can we dissallow /admin/ prefix automatically?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: teknoid</title>
		<link>http://teknoid.wordpress.com/2009/01/12/462/#comment-1835</link>
		<dc:creator>teknoid</dc:creator>
		<pubDate>Fri, 12 Jun 2009 14:34:22 +0000</pubDate>
		<guid isPermaLink="false">http://teknoid.wordpress.com/?p=462#comment-1835</guid>
		<description>@Chirayu 

The approach would be the same, you simply need to check the role of the currently logged-in user.</description>
		<content:encoded><![CDATA[<p>@Chirayu </p>
<p>The approach would be the same, you simply need to check the role of the currently logged-in user.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chirayu</title>
		<link>http://teknoid.wordpress.com/2009/01/12/462/#comment-1834</link>
		<dc:creator>Chirayu</dc:creator>
		<pubDate>Fri, 12 Jun 2009 13:15:00 +0000</pubDate>
		<guid isPermaLink="false">http://teknoid.wordpress.com/?p=462#comment-1834</guid>
		<description>Hi techno,

I went through your tutorial. I had a query on using auth component for Registered users as well as Admin users. You replied that its possible if your user table has the role field.

I am using table structure which has Many to Many relations with User and Role and maintained into separate table called users_roles. Typically I have followed the structure posted here : http://www.studiocanaria.com/articles/cakephp_auth_component_users_gro

can you suggest in brief what should be the approach, or some code example.</description>
		<content:encoded><![CDATA[<p>Hi techno,</p>
<p>I went through your tutorial. I had a query on using auth component for Registered users as well as Admin users. You replied that its possible if your user table has the role field.</p>
<p>I am using table structure which has Many to Many relations with User and Role and maintained into separate table called users_roles. Typically I have followed the structure posted here : <a href="http://www.studiocanaria.com/articles/cakephp_auth_component_users_gro" rel="nofollow">http://www.studiocanaria.com/articles/cakephp_auth_component_users_gro</a></p>
<p>can you suggest in brief what should be the approach, or some code example.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kicaj</title>
		<link>http://teknoid.wordpress.com/2009/01/12/462/#comment-1776</link>
		<dc:creator>kicaj</dc:creator>
		<pubDate>Sun, 24 May 2009 21:15:07 +0000</pubDate>
		<guid isPermaLink="false">http://teknoid.wordpress.com/?p=462#comment-1776</guid>
		<description>Okey:) I found soultion: http://teknoid.wordpress.com/2008/11/28/cakephp-url-based-language-switching-for-i18n-and-l10n-internationalization-and-localization/#comment-1515

But, Can i use admin prefix and language code together? How?</description>
		<content:encoded><![CDATA[<p>Okey:) I found soultion: <a href="http://teknoid.wordpress.com/2008/11/28/cakephp-url-based-language-switching-for-i18n-and-l10n-internationalization-and-localization/#comment-1515" rel="nofollow">http://teknoid.wordpress.com/2008/11/28/cakephp-url-based-language-switching-for-i18n-and-l10n-internationalization-and-localization/#comment-1515</a></p>
<p>But, Can i use admin prefix and language code together? How?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kicaj</title>
		<link>http://teknoid.wordpress.com/2009/01/12/462/#comment-1775</link>
		<dc:creator>kicaj</dc:creator>
		<pubDate>Sun, 24 May 2009 19:30:16 +0000</pubDate>
		<guid isPermaLink="false">http://teknoid.wordpress.com/?p=462#comment-1775</guid>
		<description>I have next problem, hehe again:p

When i add &#039;language&#039; to my url (eg. in form action) i can&#039;t loggin to admin area, why?
I use app_helper to add language, it&#039;t very simple...</description>
		<content:encoded><![CDATA[<p>I have next problem, hehe again:p</p>
<p>When i add &#8216;language&#8217; to my url (eg. in form action) i can&#8217;t loggin to admin area, why?<br />
I use app_helper to add language, it&#8217;t very simple&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: teknoid</title>
		<link>http://teknoid.wordpress.com/2009/01/12/462/#comment-1769</link>
		<dc:creator>teknoid</dc:creator>
		<pubDate>Wed, 20 May 2009 21:30:56 +0000</pubDate>
		<guid isPermaLink="false">http://teknoid.wordpress.com/?p=462#comment-1769</guid>
		<description>@kicaj 

You certainly can use it in App Controller.
Usually this happens when you try to login/logout and leads you back to the page you came from, which creates a infinite loop.

That being said, it&#039;s best to specify which actions you are &quot;allowing&quot; in the specific controller.</description>
		<content:encoded><![CDATA[<p>@kicaj </p>
<p>You certainly can use it in App Controller.<br />
Usually this happens when you try to login/logout and leads you back to the page you came from, which creates a infinite loop.</p>
<p>That being said, it&#8217;s best to specify which actions you are &#8220;allowing&#8221; in the specific controller.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
