<?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: Symfony 1.2, Propel, and sfGuardPlugin: email login</title>
	<atom:link href="http://bluehorn.co.nz/2009/06/12/symfony-12-propel-and-sfguardplugin-email-login/feed/" rel="self" type="application/rss+xml" />
	<link>http://bluehorn.co.nz/2009/06/12/symfony-12-propel-and-sfguardplugin-email-login/</link>
	<description>New Zealand Web Design &#38; Development (PHP 5, MySQL, Symfony Framework, Apache, Linux)</description>
	<lastBuildDate>Fri, 09 Dec 2011 18:27:36 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Hardeep Khehra</title>
		<link>http://bluehorn.co.nz/2009/06/12/symfony-12-propel-and-sfguardplugin-email-login/comment-page-1/#comment-2680</link>
		<dc:creator>Hardeep Khehra</dc:creator>
		<pubDate>Mon, 22 Feb 2010 02:14:05 +0000</pubDate>
		<guid isPermaLink="false">http://bluehorn.co.nz/?p=251#comment-2680</guid>
		<description>&lt;a href=&quot;#comment-2659&quot; rel=&quot;nofollow&quot;&gt;@YH &lt;/a&gt; 
There is a much easier way to do this.  I usually allow logins by email &amp; username since the user may remember one or the other more easily.

in your generated lib/model/doctrine/sfGuardUserTable.php  add the following method:

  public function retrieveByUsername($username, $isActive = true)
  {
    $query = Doctrine::getTable(&#039;sfGuardUser&#039;)-&gt;createQuery(&#039;u&#039;)
      -&gt;leftJoin(&#039;u.Profile p&#039;)
      -&gt;where(&#039;u.username = ?&#039;, $username)
      -&gt;orWhere(&#039;p.email = ?&#039;, $username)
      -&gt;addWhere(&#039;u.is_active = ?&#039;, $isActive)
    ;

    return $query-&gt;fetchOne();
  }


Thats it.. now your users can log in via email or via username.  You can adjust the Doctrine query to your liking if you only want to allow emails.

sfDoctrineGuardPlugin calls that method from the validator, but you are just overriding it with a custom query. 

from plugin documentation:

Validators
sfDoctrineGuardPlugin comes with a validator that you can use in your modules: sfGuardUserValidator.

This validator is used by the sfGuardAuth module to validate a user and password and automatically signin the user.</description>
		<content:encoded><![CDATA[<p><a href="#comment-2659" rel="nofollow">@YH </a><br />
There is a much easier way to do this.  I usually allow logins by email &amp; username since the user may remember one or the other more easily.</p>
<p>in your generated lib/model/doctrine/sfGuardUserTable.php  add the following method:</p>
<p>  public function retrieveByUsername($username, $isActive = true)<br />
  {<br />
    $query = Doctrine::getTable(&#8216;sfGuardUser&#8217;)-&gt;createQuery(&#8216;u&#8217;)<br />
      -&gt;leftJoin(&#8216;u.Profile p&#8217;)<br />
      -&gt;where(&#8216;u.username = ?&#8217;, $username)<br />
      -&gt;orWhere(&#8216;p.email = ?&#8217;, $username)<br />
      -&gt;addWhere(&#8216;u.is_active = ?&#8217;, $isActive)<br />
    ;</p>
<p>    return $query-&gt;fetchOne();<br />
  }</p>
<p>Thats it.. now your users can log in via email or via username.  You can adjust the Doctrine query to your liking if you only want to allow emails.</p>
<p>sfDoctrineGuardPlugin calls that method from the validator, but you are just overriding it with a custom query. </p>
<p>from plugin documentation:</p>
<p>Validators<br />
sfDoctrineGuardPlugin comes with a validator that you can use in your modules: sfGuardUserValidator.</p>
<p>This validator is used by the sfGuardAuth module to validate a user and password and automatically signin the user.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: YH</title>
		<link>http://bluehorn.co.nz/2009/06/12/symfony-12-propel-and-sfguardplugin-email-login/comment-page-1/#comment-2659</link>
		<dc:creator>YH</dc:creator>
		<pubDate>Sat, 20 Feb 2010 04:32:26 +0000</pubDate>
		<guid isPermaLink="false">http://bluehorn.co.nz/?p=251#comment-2659</guid>
		<description>Good tutorial. but it use with propel. so can u show some tips use with doctrine. i need integrate it with doctrine. i can&#039;t find solution use with doctrine. anyone can help.
thanks</description>
		<content:encoded><![CDATA[<p>Good tutorial. but it use with propel. so can u show some tips use with doctrine. i need integrate it with doctrine. i can&#8217;t find solution use with doctrine. anyone can help.<br />
thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott</title>
		<link>http://bluehorn.co.nz/2009/06/12/symfony-12-propel-and-sfguardplugin-email-login/comment-page-1/#comment-1471</link>
		<dc:creator>Scott</dc:creator>
		<pubDate>Tue, 13 Oct 2009 17:39:11 +0000</pubDate>
		<guid isPermaLink="false">http://bluehorn.co.nz/?p=251#comment-1471</guid>
		<description>Thanks for this clear, concise, informative tutorial.  Very helpful!</description>
		<content:encoded><![CDATA[<p>Thanks for this clear, concise, informative tutorial.  Very helpful!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kc</title>
		<link>http://bluehorn.co.nz/2009/06/12/symfony-12-propel-and-sfguardplugin-email-login/comment-page-1/#comment-919</link>
		<dc:creator>kc</dc:creator>
		<pubDate>Tue, 25 Aug 2009 11:02:21 +0000</pubDate>
		<guid isPermaLink="false">http://bluehorn.co.nz/?p=251#comment-919</guid>
		<description>Flawless integration. Great article, only took about 10 minutes to integrate into an existing application.</description>
		<content:encoded><![CDATA[<p>Flawless integration. Great article, only took about 10 minutes to integrate into an existing application.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

