<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>OnRails.org: Auto-login</title>
    <link>http://www.onrails.org/articles/2006/02/18/auto-login</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Ruby On Rails and related matters.</description>
    <item>
      <title>Auto-login</title>
      <description>&lt;p&gt;One of my midnight Rails projects is a &amp;#8220;time tracking&amp;#8221; application for which I needed auto-login. You know, the &amp;#8220;Remember me&amp;#8221; check box so that you don&amp;#8217;t have to login each time you visit the application.  I found a nice article written by Matt McCray describing how this was implemented for TaskThis.com at http://www.mattmccray.com/archives/category/software/rails/taskthis/. Even further he provides the full source code for the application.  I didn&amp;#8217;t take directly his auto_login.rb module but was greatly inspired by it. I also used the &lt;em&gt;Login Engine Plugin&lt;/em&gt; that was not providing this feature, maybe this changed, so it could be simpler, but how simple implementing the auto-login can be. Note these are not the full classes just pertinent code extracts.&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;1. Remember me&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;When the user login and checks the &amp;#8220;Remember me&amp;#8221; checkbox, the :save_login parameter is set, the User instance remember_me method invoked and the :auth_token cookie set.&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="keyword"&gt;class &lt;/span&gt;&lt;span class="class"&gt;AccountController&lt;/span&gt; &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt; &lt;span class="constant"&gt;ApplicationController&lt;/span&gt;
  &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;login&lt;/span&gt;
    &lt;span class="keyword"&gt;case&lt;/span&gt; &lt;span class="attribute"&gt;@request&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;method&lt;/span&gt;
      &lt;span class="keyword"&gt;when&lt;/span&gt; &lt;span class="symbol"&gt;:post&lt;/span&gt;
      &lt;span class="keyword"&gt;if&lt;/span&gt; &lt;span class="attribute"&gt;@session&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:user&lt;/span&gt;&lt;span class="punct"&gt;]&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;User&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;authenticate&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="attribute"&gt;@params&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:user_login&lt;/span&gt;&lt;span class="punct"&gt;],&lt;/span&gt; &lt;span class="attribute"&gt;@params&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:user_password&lt;/span&gt;&lt;span class="punct"&gt;])&lt;/span&gt;
        &lt;span class="ident"&gt;flash&lt;/span&gt;&lt;span class="punct"&gt;['&lt;/span&gt;&lt;span class="string"&gt;notice&lt;/span&gt;&lt;span class="punct"&gt;']&lt;/span&gt;  &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;Login successful&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
        &lt;span class="keyword"&gt;if&lt;/span&gt; &lt;span class="attribute"&gt;@params&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:save_login&lt;/span&gt;&lt;span class="punct"&gt;]&lt;/span&gt; &lt;span class="punct"&gt;==&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;1&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
          &lt;span class="attribute"&gt;@session&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:user&lt;/span&gt;&lt;span class="punct"&gt;].&lt;/span&gt;&lt;span class="ident"&gt;remember_me&lt;/span&gt;
          &lt;span class="ident"&gt;cookies&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:auth_token&lt;/span&gt;&lt;span class="punct"&gt;]&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;{&lt;/span&gt; &lt;span class="symbol"&gt;:value&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="attribute"&gt;@session&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:user&lt;/span&gt;&lt;span class="punct"&gt;].&lt;/span&gt;&lt;span class="ident"&gt;remember_token&lt;/span&gt; &lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="symbol"&gt;:expires&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="attribute"&gt;@session&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:user&lt;/span&gt;&lt;span class="punct"&gt;].&lt;/span&gt;&lt;span class="ident"&gt;remember_token_expires&lt;/span&gt; &lt;span class="punct"&gt;}&lt;/span&gt;
        &lt;span class="keyword"&gt;end&lt;/span&gt;
        &lt;span class="ident"&gt;redirect_back_or_default&lt;/span&gt; &lt;span class="symbol"&gt;:controller&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;time&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
      &lt;span class="keyword"&gt;else&lt;/span&gt;
        &lt;span class="ident"&gt;flash&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;now&lt;/span&gt;&lt;span class="punct"&gt;['&lt;/span&gt;&lt;span class="string"&gt;notice&lt;/span&gt;&lt;span class="punct"&gt;']&lt;/span&gt;  &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;Login unsuccessful&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
        &lt;span class="attribute"&gt;@login&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="attribute"&gt;@params&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:user_login&lt;/span&gt;&lt;span class="punct"&gt;]&lt;/span&gt;
      &lt;span class="keyword"&gt;end&lt;/span&gt;
    &lt;span class="keyword"&gt;end&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;

  &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;logout&lt;/span&gt;
    &lt;span class="attribute"&gt;@session&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:user&lt;/span&gt;&lt;span class="punct"&gt;].&lt;/span&gt;&lt;span class="ident"&gt;forget_me&lt;/span&gt; &lt;span class="keyword"&gt;if&lt;/span&gt; &lt;span class="attribute"&gt;@session&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:user&lt;/span&gt;&lt;span class="punct"&gt;]&lt;/span&gt;
    &lt;span class="attribute"&gt;@session&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:user&lt;/span&gt;&lt;span class="punct"&gt;]&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;nil&lt;/span&gt;
    &lt;span class="ident"&gt;cookies&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;delete&lt;/span&gt; &lt;span class="symbol"&gt;:auth_token&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;&lt;strong&gt;2. login_from_cookie&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;The next time the user visits the website the &amp;#8220;login_from_cookie&amp;#8221; filter is triggered. This method checks that the user is not logged in and that the :auth_token cookie is set. If that&amp;#8217;s the case the user matching the :auth_token is searched and the token_expiration verified the the user is automatically logged in. Et voila!
I guess auto_login would be more appropriate as method name.&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="keyword"&gt;class &lt;/span&gt;&lt;span class="class"&gt;ApplicationController&lt;/span&gt; &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt; &lt;span class="constant"&gt;ActionController&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;Base&lt;/span&gt;
   &lt;span class="ident"&gt;before_filter&lt;/span&gt; &lt;span class="symbol"&gt;:login_from_cookie&lt;/span&gt;
   &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;login_from_cookie&lt;/span&gt;
      &lt;span class="keyword"&gt;return&lt;/span&gt; &lt;span class="keyword"&gt;unless&lt;/span&gt; &lt;span class="ident"&gt;cookies&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:auth_token&lt;/span&gt;&lt;span class="punct"&gt;]&lt;/span&gt; &lt;span class="punct"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="attribute"&gt;@session&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:user&lt;/span&gt;&lt;span class="punct"&gt;].&lt;/span&gt;&lt;span class="ident"&gt;nil?&lt;/span&gt;
      &lt;span class="ident"&gt;user&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;User&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;find_by_remember_token&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;cookies&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:auth_token&lt;/span&gt;&lt;span class="punct"&gt;])&lt;/span&gt; 
      &lt;span class="keyword"&gt;if&lt;/span&gt; &lt;span class="ident"&gt;user&lt;/span&gt; &lt;span class="punct"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="punct"&gt;!&lt;/span&gt;&lt;span class="ident"&gt;user&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;remember_token_expires&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;nil?&lt;/span&gt; &lt;span class="punct"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="constant"&gt;Time&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;now&lt;/span&gt; &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt; &lt;span class="ident"&gt;user&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;remember_token_expires&lt;/span&gt; 
         &lt;span class="attribute"&gt;@session&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="symbol"&gt;:user&lt;/span&gt;&lt;span class="punct"&gt;]&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="ident"&gt;user&lt;/span&gt;
      &lt;span class="keyword"&gt;end&lt;/span&gt;
   &lt;span class="keyword"&gt;end&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;&lt;strong&gt;3. the User class&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;The User class has two methods to set and remove the token from the database. It&amp;#8217;s pretty secure as from the token the user cannot be identified without having the salt, the email, and the token expiration, which is most unlikely to be recreated. It could be even more secure by just encrypting some random unique identifier. The only issue I encountered was that the user class always forces the password validation and encryption when saving.   For now I just bypass validation and encryption when setting and clearing the remember_me token.&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="keyword"&gt;class &lt;/span&gt;&lt;span class="class"&gt;User&lt;/span&gt; &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt; &lt;span class="constant"&gt;ActiveRecord&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;Base&lt;/span&gt;
  &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;remember_me&lt;/span&gt;
    &lt;span class="constant"&gt;self&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;remember_token_expires&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="number"&gt;2&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;weeks&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;from_now&lt;/span&gt;
    &lt;span class="constant"&gt;self&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;remember_token&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;Digest&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;SHA1&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;hexdigest&lt;/span&gt;&lt;span class="punct"&gt;(&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;&lt;span class="expr"&gt;#{salt}&lt;/span&gt;--&lt;span class="expr"&gt;#{self.email}&lt;/span&gt;--&lt;span class="expr"&gt;#{self.remember_token_expires}&lt;/span&gt;&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;)&lt;/span&gt;
    &lt;span class="constant"&gt;self&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;password&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;  &lt;span class="comment"&gt;# This bypasses password encryption, thus leaving password intact&lt;/span&gt;
    &lt;span class="constant"&gt;self&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;save_with_validation&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="constant"&gt;false&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;

  &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;forget_me&lt;/span&gt;
    &lt;span class="constant"&gt;self&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;remember_token_expires&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;nil&lt;/span&gt;
    &lt;span class="constant"&gt;self&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;remember_token&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;nil&lt;/span&gt;
    &lt;span class="constant"&gt;self&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;password&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;  &lt;span class="comment"&gt;# This bypasses password encryption, thus leaving password intact&lt;/span&gt;
    &lt;span class="constant"&gt;self&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;save_with_validation&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="constant"&gt;false&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
      <pubDate>Sat, 18 Feb 2006 13:41:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:b572b35d-2d33-4199-a7f4-98867c6eb353</guid>
      <author>Daniel Wanja</author>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login</link>
    </item>
    <item>
      <title>"Auto-login" by Brett  </title>
      <description>&lt;p&gt;Nice function.  I wish I would have found this article earlier, the use of an auth_token for the the session variable makes it much easier.  I using up doing this:&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://www.thewojogroup.com/2008/09/remember-mes-with-rails/" rel="nofollow"&gt;http://www.thewojogroup.com/2008/09/remember-mes-with-rails/&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;haha exactly what the guy above posted.&lt;/p&gt;</description>
      <pubDate>Tue, 30 Sep 2008 17:16:52 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:6c2967fd-c62a-4370-bc8f-b20f1cb5410f</guid>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login#comment-4032</link>
    </item>
    <item>
      <title>"Auto-login" by steve</title>
      <description>&lt;p&gt;You can also check this out, Really Simple Remember Me&amp;#8217;s. &lt;a href="http://www.thewojogroup.com/2008/09/remember-mes-with-rails/" rel="nofollow"&gt;http://www.thewojogroup.com/2008/09/remember-mes-with-rails/&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Sat, 27 Sep 2008 14:26:55 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:902dc4bb-33cf-4dc5-9547-a7714fcd7c02</guid>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login#comment-4025</link>
    </item>
    <item>
      <title>"Auto-login" by aageboi</title>
      <description>&lt;p&gt;so much thanks&lt;/p&gt;</description>
      <pubDate>Sat, 08 Dec 2007 05:07:50 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:ee2673d3-6f02-438f-abb9-35f3035ef93c</guid>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login#comment-3023</link>
    </item>
    <item>
      <title>"Auto-login" by top online poker casinos</title>
      <description>&lt;p&gt;Type curtsied that online poker assistant. A action is diabolically overall. I lent that play internet poker online away from some online poker assistant. Some Learn to Play Poker is ferociously agreed. Some section is embarrassingly excess. Some missing online poker assistant was above the established report. In my opinion, this community is less favourable than an essential room. View fidgeted some Learn to Play Poker. It&amp;#8217;s romantic to be mislaid! It&amp;#8217;s vocational to be directed! It&amp;#8217;s driving to be taped! According to common sense, one Learn to Play Poker is far more gothic than the meaningful approach&amp;#8230;&lt;/p&gt;</description>
      <pubDate>Sun, 07 Oct 2007 11:24:38 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:1b615e16-2106-4a38-a1e1-6c1e66e73d11</guid>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login#comment-2664</link>
    </item>
    <item>
      <title>"Auto-login" by nitin@vinfotech.com</title>
      <description>&lt;p&gt;hi,
I am a newbie cum naive to programming. But intrested in developing the Autologin feature for IE/Firefox/ basically windows base in C#. Can anybody guide me&amp;#8230;.....plz&lt;/p&gt;</description>
      <pubDate>Fri, 13 Jul 2007 06:07:45 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:6917c8d8-5e4d-4f58-8604-a835306372a5</guid>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login#comment-2442</link>
    </item>
    <item>
      <title>"Auto-login" by Lee</title>
      <description>&lt;p&gt;hexcatalyst,&lt;/p&gt;


	&lt;p&gt;It sounds like you&amp;#8217;re having an issue specific to the login_engine from the rails engine plugin.  We don&amp;#8217;t use that plugin, so you may want to check with their &lt;a href="http://rails-engines.org/bugs"&gt;support area&lt;/a&gt; for help.  It looks like the rails engine plugin might have even &lt;a href="http://rails-engines.org/news/2007/01/23/farewell-login_engine-/"&gt;dropped&lt;/a&gt; the login_engine from the latest release.&lt;/p&gt;


	&lt;p&gt;Good luck.&lt;/p&gt;


	&lt;p&gt;-Lee&lt;/p&gt;</description>
      <pubDate>Wed, 13 Jun 2007 15:28:26 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:f5a7912a-8dc9-4edd-baca-7eabdd29b505</guid>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login#comment-2305</link>
    </item>
    <item>
      <title>"Auto-login" by hexcatalyst@gmail.com</title>
      <description>&lt;p&gt;when i put this to environment.rb&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;module LoginEngine
   config :salt, "your-salt-here" 
 end&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;Engines.start :login&lt;/p&gt;


	&lt;p&gt;&amp;#8212;-&amp;#8212;-&amp;#8212;-&amp;#8212;-&amp;#8212;-&amp;#8212;-&amp;#8212;-&amp;#8212;-&lt;/p&gt;


	&lt;p&gt;i get problem when starting up the server.&lt;/p&gt;</description>
      <pubDate>Wed, 13 Jun 2007 06:04:24 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:c7b6d51a-7814-4e5c-8810-d5a691c6d153</guid>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login#comment-2304</link>
    </item>
    <item>
      <title>"Auto-login" by hexcatalyst@gmail.com</title>
      <description>&lt;p&gt;Hi,
I&amp;#8217;m using login engine as my plugins on rails.&lt;/p&gt;


	&lt;p&gt;I cerated model and controller then I follow the instructions and added user in the database.&lt;/p&gt;


	&lt;p&gt;When I reload the page: &amp;#8220;we&amp;#8217;re sorry something went wrong&amp;#8230;.&amp;#8221;&lt;/p&gt;


	&lt;p&gt;Can anyone help me? please email me. 
any help would be greatly appreciated&lt;/p&gt;


	&lt;p&gt;Thanks&lt;/p&gt;</description>
      <pubDate>Wed, 13 Jun 2007 03:04:15 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:48d3cef6-1fb9-4229-b390-4d56d308a98e</guid>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login#comment-2303</link>
    </item>
    <item>
      <title>"Auto-login" by srinu_s@yahoo.com</title>
      <description>&lt;p&gt;I am new to ror&lt;/p&gt;


	&lt;p&gt;very nice article&amp;#8230;thanks&lt;/p&gt;</description>
      <pubDate>Sat, 09 Jun 2007 23:47:53 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:8a922d75-cf6e-4986-8a94-77ee0089bcac</guid>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login#comment-2267</link>
    </item>
    <item>
      <title>"Auto-login" by Daniel Wanja</title>
      <description>&lt;p&gt;Hi John,&lt;/p&gt;


	&lt;p&gt;If you are talking about time.onrails.org just try to enter any password and press the login button, then a &amp;#8216;forgot password&amp;#8217; link will appear and your password will be emailed to you.&lt;/p&gt;</description>
      <pubDate>Tue, 27 Feb 2007 13:48:06 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:9d87ed0a-d41f-4543-8178-7092e4a3aff5</guid>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login#comment-264</link>
    </item>
    <item>
      <title>"Auto-login" by ngw</title>
      <description>&lt;p&gt;Hi, I&amp;#8217;m trying to write a functional test for this, but I&amp;#8217;m not able to make it work &amp;#8230;&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;def test_authentication_with_cookie
  post :login, { :username =&amp;gt; 'foo', :password =&amp;gt; 'passwd', :remember_me =&amp;gt; '1' }
  user = User.find(:first, session[:user_id])
  puts cookies['auth_token'].inspect
  assert_equal cookies['auth_token'].value, user.remember_token
  assert_equal cookies['auth_token'].expires, user.remember_token_expiration
end&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;How do you test it ?&lt;/p&gt;</description>
      <pubDate>Wed, 21 Feb 2007 13:40:49 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:ba63ac5d-4630-4f50-a46b-bc5d37d3d843</guid>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login#comment-252</link>
    </item>
    <item>
      <title>"Auto-login" by Niall Doherty</title>
      <description>&lt;p&gt;I had some difficulty getting this to work with the SaltedHashLoginGenerator, but finally got it. Turns out you need to create two extra columns in your &lt;b&gt;users&lt;/b&gt; table (or equivalent).&lt;/p&gt;


	&lt;p&gt;remember_token_expires &amp;#8230; datetime&lt;br /&gt;
remember_token &amp;#8230; varchar(40)&lt;/p&gt;


	&lt;p&gt;Thanks for this, Daniel.&lt;/p&gt;</description>
      <pubDate>Sun, 18 Feb 2007 12:11:29 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:b0964500-48f6-4645-94b1-6e57a95bd8eb</guid>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login#comment-248</link>
    </item>
    <item>
      <title>"Auto-login" by Niall Doherty</title>
      <description>&lt;p&gt;I had some difficulty getting this to work with the SaltedHashLoginGenerator, but finally got it. Turns out you need to create two extra columns in your &lt;b&gt;users&lt;/b&gt; table (or equivalent).&lt;/p&gt;


	&lt;p&gt;remember_token_expires &amp;#8230; datetime&lt;br /&gt;
remember_token &amp;#8230; varchar(40)&lt;/p&gt;


	&lt;p&gt;Thanks for this, Daniel.&lt;/p&gt;</description>
      <pubDate>Sun, 18 Feb 2007 12:11:15 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:cedf23ab-e39a-4422-8663-6b5516bc768f</guid>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login#comment-247</link>
    </item>
    <item>
      <title>"Auto-login" by Daniel Wanja</title>
      <description>&lt;p&gt;Thanks for the feedback on how this site renders in IE. You are correct, it&amp;#8217;s a little messed up. It&amp;#8217;s even worth in IE7. We are currently moving this blog to media template. During that process I will change the template to work as well on IE. Note this may also explain why only 15.41% of reader of this blog are using IE while 66.76 are using Firefox and 10.27% are using Safari.&lt;/p&gt;</description>
      <pubDate>Fri, 12 Jan 2007 09:16:21 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:3a44bfd0-de7a-4857-82d3-2a2af8078ccf</guid>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login#comment-214</link>
    </item>
    <item>
      <title>"Auto-login" by dude</title>
      <description>&lt;p&gt;i mean this website! not the code that is being given. The code I haven&amp;#8217;t tried, but probably works.&lt;/p&gt;</description>
      <pubDate>Wed, 10 Jan 2007 02:24:18 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:c42d4f81-6368-45da-8b9b-091a3774610a</guid>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login#comment-213</link>
    </item>
    <item>
      <title>"Auto-login" by dude</title>
      <description>&lt;p&gt;this website looks all messed up when it renders on Internet Explorer 1.6 and slightly less ( but still messed up) on firefox 2.0&lt;/p&gt;</description>
      <pubDate>Wed, 10 Jan 2007 02:23:06 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:4ba5fb06-3d8c-4f3a-bb29-cf203c75c222</guid>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login#comment-212</link>
    </item>
    <item>
      <title>"Auto-login" by Steve Jernigan</title>
      <description>&lt;p&gt;Anyone else had/having a problem with Safari and this solution?  Any fixes?&lt;/p&gt;</description>
      <pubDate>Wed, 18 Oct 2006 07:09:36 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:bb3d665c-1dca-49ed-8317-7afcd324de07</guid>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login#comment-165</link>
    </item>
    <item>
      <title>"Auto-login" by Daniel Wanja</title>
      <description>On a new Rails project I am working on we are using the acts_as_authenticated which I quite like. See &lt;a&gt;http://technoweenie.stikipad.com/plugins/show/Acts&lt;/a&gt;+as+Authenticated for more info. I also stumbled upon a detailed article at &lt;a&gt;http://www.aidanf.net/rails_user_authentication_tutorial&lt;/a&gt;.</description>
      <pubDate>Mon, 19 Jun 2006 18:50:25 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:ecdcf4a6-ef68-46a1-a839-325427755a53</guid>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login#comment-114</link>
    </item>
    <item>
      <title>"Auto-login" by freetwix</title>
      <description>hey, the code beneath will resolve any problems with the password (in my case) and do not need any hacks. by the way, thanks for the article, daniel.

&lt;p&gt;
def remember_me&lt;br /&gt;
  update_attributes(&lt;br /&gt;
    :remember_token_expires =&gt; 2.weeks.from_now, &lt;br /&gt;
    :remember_token =&gt; Digest::SHA1.hexdigest("#{salt}--#{self.email}--#{self.remember_token_expires}"))&lt;br /&gt;
end
&lt;/p&gt;</description>
      <pubDate>Tue, 06 Jun 2006 07:03:25 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:b0bba59c-c886-4a83-b739-e8e62687a973</guid>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login#comment-112</link>
    </item>
    <item>
      <title>"Auto-login" by Daniel Wanja</title>
      <description>Correct. This is a flaw when login from two different computers the second login would override the token of the first login. This can be fixed by testing if a token is already set on the user and re-use the existing token. Hence the same token would be valid from two different pc. I believe Lee fixed this on time.onrails.org as this was really was enoying him. </description>
      <pubDate>Sun, 28 May 2006 21:10:27 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:69585757-6ba5-4f4c-bf2f-21fe4c4a9f4d</guid>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login#comment-110</link>
    </item>
    <item>
      <title>"Auto-login" by albus522</title>
      <description>This only has one flaw that I can see. That is that you are limited to one computer for autologin. If you choose remember me on another computer the hash will be changed and when you go back to the original computer you will not be logged in.</description>
      <pubDate>Sun, 28 May 2006 18:47:46 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:d5fb70a2-69f7-4320-a4fc-60250492f011</guid>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login#comment-109</link>
    </item>
    <item>
      <title>"Auto-login" by Daniel Wanja</title>
      <description>Glad it worked for you. I haven't added the change to the original login engine as I still added more changes to the version I used so it's not too generic anymore. One of the changes was not to store the User itself in the session, but only the user id.</description>
      <pubDate>Fri, 19 May 2006 15:10:10 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:fcea7bc2-ee9e-46c5-bd3a-d97ce2346216</guid>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login#comment-106</link>
    </item>
    <item>
      <title>"Auto-login" by jungly</title>
      <description>saved my day too. muchos gracias</description>
      <pubDate>Fri, 19 May 2006 14:44:33 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:cdb73152-1919-4e88-9ef3-c4c06b7f3cbe</guid>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login#comment-105</link>
    </item>
    <item>
      <title>"Auto-login" by Problem Solvings Skills</title>
      <description>Very nice. Is the changes made to the original login engine source?</description>
      <pubDate>Thu, 18 May 2006 18:00:11 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:7261a204-e5ae-4e5d-887a-b1f8a1507a4f</guid>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login#comment-104</link>
    </item>
    <item>
      <title>"Auto-login" by Yardboy</title>
      <description>Appreciate you posting this, helped me a ton - nice work!</description>
      <pubDate>Sat, 06 May 2006 10:07:53 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:32292405-c55c-4467-a33d-ea47e4b58d47</guid>
      <link>http://www.onrails.org/articles/2006/02/18/auto-login#comment-73</link>
    </item>
  </channel>
</rss>
