<?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"
	>
<channel>
	<title>Comments on: 5 Minute Beta Authentication in Rails</title>
	<atom:link href="http://www.igvita.com/2007/06/21/5-minute-beta-authentication-in-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.igvita.com/2007/06/21/5-minute-beta-authentication-in-rails/</link>
	<description>A goal is a dream with a deadline.</description>
	<pubDate>Fri, 29 Aug 2008 02:57:43 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Ilya Grigorik</title>
		<link>http://www.igvita.com/2007/06/21/5-minute-beta-authentication-in-rails/#comment-102266</link>
		<dc:creator>Ilya Grigorik</dc:creator>
		<pubDate>Sun, 30 Mar 2008 01:39:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.igvita.com/blog/2007/06/21/5-minute-beta-authentication-in-rails/#comment-102266</guid>
		<description>Cedric, are you volunteering? ;)</description>
		<content:encoded><![CDATA[<p>Cedric, are you volunteering? ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cédric DELTHEIL</title>
		<link>http://www.igvita.com/2007/06/21/5-minute-beta-authentication-in-rails/#comment-102231</link>
		<dc:creator>Cédric DELTHEIL</dc:creator>
		<pubDate>Tue, 25 Mar 2008 12:36:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.igvita.com/blog/2007/06/21/5-minute-beta-authentication-in-rails/#comment-102231</guid>
		<description>Thank you guys!

I used this hack with Ilya's recipe in a customized version of restful_authentication. Wouldn't it be great to package this stuff in a plugin?!</description>
		<content:encoded><![CDATA[<p>Thank you guys!</p>
<p>I used this hack with Ilya&#8217;s recipe in a customized version of restful_authentication. Wouldn&#8217;t it be great to package this stuff in a plugin?!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ilya Grigorik</title>
		<link>http://www.igvita.com/2007/06/21/5-minute-beta-authentication-in-rails/#comment-102112</link>
		<dc:creator>Ilya Grigorik</dc:creator>
		<pubDate>Tue, 18 Mar 2008 12:34:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.igvita.com/blog/2007/06/21/5-minute-beta-authentication-in-rails/#comment-102112</guid>
		<description>Go Cedric, go!</description>
		<content:encoded><![CDATA[<p>Go Cedric, go!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BM5k</title>
		<link>http://www.igvita.com/2007/06/21/5-minute-beta-authentication-in-rails/#comment-102086</link>
		<dc:creator>BM5k</dc:creator>
		<pubDate>Mon, 17 Mar 2008 09:38:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.igvita.com/blog/2007/06/21/5-minute-beta-authentication-in-rails/#comment-102086</guid>
		<description>It's been quite a while, but I wanted to say thanks for this example! I'm using a modified version of Cédric's code in my project It's a LOT cleaner and easier than what I was trying to do.</description>
		<content:encoded><![CDATA[<p>It&#8217;s been quite a while, but I wanted to say thanks for this example! I&#8217;m using a modified version of Cédric&#8217;s code in my project It&#8217;s a LOT cleaner and easier than what I was trying to do.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ilya Grigorik</title>
		<link>http://www.igvita.com/2007/06/21/5-minute-beta-authentication-in-rails/#comment-100709</link>
		<dc:creator>Ilya Grigorik</dc:creator>
		<pubDate>Thu, 27 Dec 2007 05:01:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.igvita.com/blog/2007/06/21/5-minute-beta-authentication-in-rails/#comment-100709</guid>
		<description>Cedric, clever stuff and nice pattern! I can think of a few spots where I can refactor my code to take advantage of this approach. :)</description>
		<content:encoded><![CDATA[<p>Cedric, clever stuff and nice pattern! I can think of a few spots where I can refactor my code to take advantage of this approach. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cédric DELTHEIL</title>
		<link>http://www.igvita.com/2007/06/21/5-minute-beta-authentication-in-rails/#comment-98481</link>
		<dc:creator>Cédric DELTHEIL</dc:creator>
		<pubDate>Fri, 14 Dec 2007 20:42:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.igvita.com/blog/2007/06/21/5-minute-beta-authentication-in-rails/#comment-98481</guid>
		<description>Hi Ilya. In the approach I described you don't have to add any additional column since I make use of a virtual attribute on User class (exactly as acts_as_authenticated does with the unencrypted password).

It takes 5 lines of code including the validators:

&lt;code&gt;
class User &lt; ActiveRecord::Base
  # Virtual attribute
  attr_accessor :beta_key
  
  validates_presence_of :beta_key, :if =&gt; Proc.new { &#124;user&#124; user.new_record? }, :message =&gt; "Please type in your beta key"
  validates_each :beta_key, :if =&gt; Proc.new { &#124;user&#124; user.new_record? }, :allow_nil =&gt; true do &#124;record, attr, value&#124;
    record.errors.add attr, "Invalid key" unless value == BetaKey.generate(record.email)
  end

  # ...
end
&lt;/code&gt;

Finally it's quite simple and efficient!</description>
		<content:encoded><![CDATA[<p>Hi Ilya. In the approach I described you don&#8217;t have to add any additional column since I make use of a virtual attribute on User class (exactly as acts_as_authenticated does with the unencrypted password).</p>
<p>It takes 5 lines of code including the validators:</p>
<p><code><br />
class User < ActiveRecord::Base<br />
  # Virtual attribute<br />
  attr_accessor :beta_key</p>
<p>  validates_presence_of :beta_key, :if => Proc.new { |user| user.new_record? }, :message => &#8220;Please type in your beta key&#8221;<br />
  validates_each :beta_key, :if => Proc.new { |user| user.new_record? }, :allow_nil => true do |record, attr, value|<br />
    record.errors.add attr, &#8220;Invalid key&#8221; unless value == BetaKey.generate(record.email)<br />
  end</p>
<p>  # &#8230;<br />
end<br />
</code></p>
<p>Finally it&#8217;s quite simple and efficient!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ilya Grigorik</title>
		<link>http://www.igvita.com/2007/06/21/5-minute-beta-authentication-in-rails/#comment-98453</link>
		<dc:creator>Ilya Grigorik</dc:creator>
		<pubDate>Fri, 14 Dec 2007 16:25:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.igvita.com/blog/2007/06/21/5-minute-beta-authentication-in-rails/#comment-98453</guid>
		<description>Cedric, that could certainly work. The only reason I decided against such an approach was due to additional maintenance of the database schemas once you remove the 'beta'. I didn't want to store an additional column of data in DB.. Having said that, you can define validations that don't have to query a database, so you can still your approach as you described it.</description>
		<content:encoded><![CDATA[<p>Cedric, that could certainly work. The only reason I decided against such an approach was due to additional maintenance of the database schemas once you remove the &#8216;beta&#8217;. I didn&#8217;t want to store an additional column of data in DB.. Having said that, you can define validations that don&#8217;t have to query a database, so you can still your approach as you described it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cédric DELTHEIL</title>
		<link>http://www.igvita.com/2007/06/21/5-minute-beta-authentication-in-rails/#comment-97807</link>
		<dc:creator>Cédric DELTHEIL</dc:creator>
		<pubDate>Tue, 11 Dec 2007 22:53:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.igvita.com/blog/2007/06/21/5-minute-beta-authentication-in-rails/#comment-97807</guid>
		<description>Hello Ilya. Very helpful article!

Here's a suggestion. Let's suppose you have a User model to hold the account information (not very original, isn't it ?!).

Guarding the sign-up could be viewed as adding validations to User.

So what about creating a beta_key virtual attribute for User (attr_accessor :beta_key) ? This allows to easily implement validators (presence and verification), use the form_for helper with a text field for key and take benefit of the various error message helpers when the validation fails.

I tried this on my own and it works pretty well.</description>
		<content:encoded><![CDATA[<p>Hello Ilya. Very helpful article!</p>
<p>Here&#8217;s a suggestion. Let&#8217;s suppose you have a User model to hold the account information (not very original, isn&#8217;t it ?!).</p>
<p>Guarding the sign-up could be viewed as adding validations to User.</p>
<p>So what about creating a beta_key virtual attribute for User (attr_accessor :beta_key) ? This allows to easily implement validators (presence and verification), use the form_for helper with a text field for key and take benefit of the various error message helpers when the validation fails.</p>
<p>I tried this on my own and it works pretty well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ilya Grigorik</title>
		<link>http://www.igvita.com/2007/06/21/5-minute-beta-authentication-in-rails/#comment-85678</link>
		<dc:creator>Ilya Grigorik</dc:creator>
		<pubDate>Tue, 13 Nov 2007 07:39:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.igvita.com/blog/2007/06/21/5-minute-beta-authentication-in-rails/#comment-85678</guid>
		<description>Tom, my code was extracted from a live application, so most of it should work as is. Having said that, every app. is different, hence it would probably still require some additional glue to make everything work.

You do need to take care of the 'key' field in your form. This can be done either through an explicit text-field, or a hidden one which is populated by a URL parameter.

In example above, the key should populate a hidden or an explicit form element in your page. I emailed the keys directly to our beta users as part of a link, hence the http://url/key structure. I wanted to allow quick sign-up with the help of a direct link.</description>
		<content:encoded><![CDATA[<p>Tom, my code was extracted from a live application, so most of it should work as is. Having said that, every app. is different, hence it would probably still require some additional glue to make everything work.</p>
<p>You do need to take care of the &#8216;key&#8217; field in your form. This can be done either through an explicit text-field, or a hidden one which is populated by a URL parameter.</p>
<p>In example above, the key should populate a hidden or an explicit form element in your page. I emailed the keys directly to our beta users as part of a link, hence the <a href="http://url/key" rel="nofollow">http://url/key</a> structure. I wanted to allow quick sign-up with the help of a direct link.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Calloway</title>
		<link>http://www.igvita.com/2007/06/21/5-minute-beta-authentication-in-rails/#comment-84997</link>
		<dc:creator>Tom Calloway</dc:creator>
		<pubDate>Mon, 12 Nov 2007 03:08:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.igvita.com/blog/2007/06/21/5-minute-beta-authentication-in-rails/#comment-84997</guid>
		<description>Running Rails 1.2.5.  Is this code and documentation complete and well-tested?  Or does one need to read in between the lines and create additional code based on experience?

For instance, is it necessary to modify the signup.html to include a form field for 'key'?

Until I commented out the custom handler, I was always redirected to main/welcome.  I added ':signup, :login, :index' to the exceptions list for the before_filter in application.rb

I have not yet been able to verify that the key generated by beta_key.rb is the same as that calculated by the signup method in account_controller.  That method does not accept the keys I submit.  Is params[:user][:email] correct in the beta_verify assignment in that method or should it be params[:email]?  Still, neither worked for me.

Also, the output of beta_key.rb is confusing, since it suggests that the key is actually submitted via the link rather than through a form.  If it's the link, then does the path /beta/#{key} make sense, given the rest of the code?</description>
		<content:encoded><![CDATA[<p>Running Rails 1.2.5.  Is this code and documentation complete and well-tested?  Or does one need to read in between the lines and create additional code based on experience?</p>
<p>For instance, is it necessary to modify the signup.html to include a form field for &#8216;key&#8217;?</p>
<p>Until I commented out the custom handler, I was always redirected to main/welcome.  I added &#8216;:signup, :login, :index&#8217; to the exceptions list for the before_filter in application.rb</p>
<p>I have not yet been able to verify that the key generated by beta_key.rb is the same as that calculated by the signup method in account_controller.  That method does not accept the keys I submit.  Is params[:user][:email] correct in the beta_verify assignment in that method or should it be params[:email]?  Still, neither worked for me.</p>
<p>Also, the output of beta_key.rb is confusing, since it suggests that the key is actually submitted via the link rather than through a form.  If it&#8217;s the link, then does the path /beta/#{key} make sense, given the rest of the code?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
