<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>db/migrate/20090115014420_create_users.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -18,7 +18,7 @@ class UsersController &lt; ApplicationController
       # button. Uncomment if you understand the tradeoffs.
       # reset session
       self.current_user = @user # !! now logged in
-      redirect_to('/?add=true')
+      redirect_back_or_default('/?add=true')
       flash[:notice] = &quot;Thanks for signing up!  We're sending you an email with your activation code.&quot;
     else
       flash[:error]  = &quot;We couldn't set up that account, sorry.  Please try again, or contact an admin (link is above).&quot;</diff>
      <filename>app/controllers/users_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,16 +7,16 @@ class User &lt; ActiveRecord::Base
 
   validates_presence_of     :login
   validates_length_of       :login,    :within =&gt; 3..40
-  validates_uniqueness_of   :login,    :case_sensitive =&gt; false
-  validates_format_of       :login,    :with =&gt; RE_LOGIN_OK, :message =&gt; MSG_LOGIN_BAD
+  validates_uniqueness_of   :login
+  validates_format_of       :login,    :with =&gt; Authentication.login_regex, :message =&gt; Authentication.bad_login_message
 
-  validates_format_of       :name,     :with =&gt; RE_NAME_OK,  :message =&gt; MSG_NAME_BAD, :allow_nil =&gt; true
+  validates_format_of       :name,     :with =&gt; Authentication.name_regex,  :message =&gt; Authentication.bad_name_message, :allow_nil =&gt; true
   validates_length_of       :name,     :maximum =&gt; 100
 
   validates_presence_of     :email
   validates_length_of       :email,    :within =&gt; 6..100 #r@a.wk
-  validates_uniqueness_of   :email,    :case_sensitive =&gt; false
-  validates_format_of       :email,    :with =&gt; RE_EMAIL_OK, :message =&gt; MSG_EMAIL_BAD
+  validates_uniqueness_of   :email
+  validates_format_of       :email,    :with =&gt; Authentication.email_regex, :message =&gt; Authentication.bad_email_message
 
   
 
@@ -34,12 +34,17 @@ class User &lt; ActiveRecord::Base
   # This will also let us return a human error message.
   #
   def self.authenticate(login, password)
+    return nil if login.blank? || password.blank?
     u = find_by_login(login) # need to get the salt
     u &amp;&amp; u.authenticated?(password) ? u : nil
   end
 
-  def name
-    return login
+  def login=(value)
+    write_attribute :login, (value ? value.downcase : nil)
+  end
+
+  def email=(value)
+    write_attribute :email, (value ? value.downcase : nil)
   end
 
   protected</diff>
      <filename>app/models/user.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,14 +1,14 @@
 &lt;h1&gt;Log In&lt;/h1&gt;
 
 &lt;% form_tag session_path do -%&gt;
-&lt;p&gt;&lt;label for=&quot;login&quot;&gt;Login&lt;/label&gt;&lt;br/&gt;
+&lt;p&gt;&lt;%= label_tag 'login' %&gt;&lt;br /&gt;
 &lt;%= text_field_tag 'login', @login %&gt;&lt;/p&gt;
 
-&lt;p&gt;&lt;label for=&quot;password&quot;&gt;Password&lt;/label&gt;&lt;br/&gt;
+&lt;p&gt;&lt;%= label_tag 'password' %&gt;&lt;br/&gt;
 &lt;%= password_field_tag 'password', nil %&gt;&lt;/p&gt;
 
 &lt;!-- Uncomment this if you want this functionality
-&lt;p&gt;&lt;label for=&quot;remember_me&quot;&gt;Remember me:&lt;/label&gt;
+&lt;p&gt;&lt;%= label_tag 'remember_me', 'Remember me' %&gt;
 &lt;%= check_box_tag 'remember_me', '1', @remember_me %&gt;&lt;/p&gt;
 --&gt;
 </diff>
      <filename>app/views/sessions/new.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -1,8 +1,8 @@
 &lt;% if logged_in? -%&gt;
   &lt;div id=&quot;user-bar-greeting&quot;&gt;Logged in as &lt;%= link_to_current_user :content_method =&gt; :login %&gt;&lt;/div&gt;
-  &lt;div id=&quot;user-bar-action&quot;  &gt;(&lt;%= link_to &quot;log out&quot;, logout_path, { :title =&gt; &quot;Log out&quot; }    %&gt;)&lt;/div&gt;
+  &lt;div id=&quot;user-bar-action&quot;  &gt;(&lt;%= link_to &quot;Log out&quot;, logout_path, { :title =&gt; &quot;Log out&quot; }    %&gt;)&lt;/div&gt;
 &lt;% else -%&gt;
-  &lt;div id=&quot;user-bar-greeting&quot;&gt;&lt;%= abbr_tag_with_IP 'Not logged in', :style =&gt; 'border: none;' %&gt;&lt;/div&gt;
+  &lt;div id=&quot;user-bar-greeting&quot;&gt;&lt;%= link_to_login_with_IP 'Not logged in', :style =&gt; 'border: none;' %&gt;&lt;/div&gt;
   &lt;div id=&quot;user-bar-action&quot;  &gt;&lt;%= link_to &quot;Log in&quot;,  login_path,  { :title =&gt; &quot;Log in&quot; } %&gt; /
                                &lt;%= link_to &quot;Sign up&quot;, signup_path, { :title =&gt; &quot;Create an account&quot; } %&gt;&lt;/div&gt;
 &lt;% end -%&gt;</diff>
      <filename>app/views/users/_user_bar.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -3,16 +3,16 @@
 
 &lt;%= error_messages_for :user %&gt;
 &lt;% form_for :user, :url =&gt; users_path do |f| -%&gt;
-&lt;p&gt;&lt;label for=&quot;login&quot;&gt;Login&lt;/label&gt;&lt;br/&gt;
+&lt;p&gt;&lt;%= label_tag 'login' %&gt;&lt;br/&gt;
 &lt;%= f.text_field :login %&gt;&lt;/p&gt;
 
-&lt;p&gt;&lt;label for=&quot;email&quot;&gt;Email&lt;/label&gt;&lt;br/&gt;
+&lt;p&gt;&lt;%= label_tag 'email' %&gt;&lt;br/&gt;
 &lt;%= f.text_field :email %&gt;&lt;/p&gt;
 
-&lt;p&gt;&lt;label for=&quot;password&quot;&gt;Password&lt;/label&gt;&lt;br/&gt;
+&lt;p&gt;&lt;%= label_tag 'password' %&gt;&lt;br/&gt;
 &lt;%= f.password_field :password %&gt;&lt;/p&gt;
 
-&lt;p&gt;&lt;label for=&quot;password_confirmation&quot;&gt;Confirm Password&lt;/label&gt;&lt;br/&gt;
+&lt;p&gt;&lt;%= label_tag 'password_confirmation', 'Confirm Password' %&gt;&lt;br/&gt;
 &lt;%= f.password_field :password_confirmation %&gt;&lt;/p&gt;
 
 &lt;p&gt;&lt;%= submit_tag 'Sign up' %&gt;&lt;/p&gt;</diff>
      <filename>app/views/users/new.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -1,23 +1,23 @@
 
 # A Site key gives additional protection against a dictionary attack if your
 # DB is ever compromised.  With no site key, we store
-#   DB_password = hash(password, DB_salt)
+#   DB_password = hash(user_password, DB_user_salt)
 # If your database were to be compromised you'd be vulnerable to a dictionary
-# attack on all your stupid clients' passwords.  With a site key, we store
-#   DB_password = hash(password, DB_salt, Code_site_key)
+# attack on all your stupid users' passwords.  With a site key, we store
+#   DB_password = hash(user_password, DB_user_salt, Code_site_key)
 # That means an attacker needs access to both your site's code *and* its
 # database to mount an &quot;offline dictionary attack.&quot;:http://www.dwheeler.com/secure-programs/Secure-Programs-HOWTO/web-authentication.html
-#
+# 
 # It's probably of minor importance, but recommended by best practices: 'defense
 # in depth'.  Needless to say, if you upload this to github or the youtubes or
-# otherwise place it in public view you'll kinda defeat the point.  Your visitors'
+# otherwise place it in public view you'll kinda defeat the point.  Your users'
 # passwords are still secure, and the world won't end, but defense_in_depth -= 1.
-#
+# 
 # Please note: if you change this, all the passwords will be invalidated, so DO
 # keep it someplace secure.  Use the random value given or type in the lyrics to
 # your favorite Jay-Z song or something; any moderately long, unpredictable text.
 REST_AUTH_SITE_KEY         = '0aba9bade1647edd7bd3a0a2d72451978a2e06f3'
-
+  
 # Repeated applications of the hash make brute force (even with a compromised
 # database and site key) harder, and scale with Moore's law.
 #
@@ -26,13 +26,13 @@ REST_AUTH_SITE_KEY         = '0aba9bade1647edd7bd3a0a2d72451978a2e06f3'
 #   so simple and obvious that they should be used in every password system.
 #   There is really no excuse not to use them.&quot; http://tinyurl.com/37lb73
 #   Practical Security (Ferguson &amp; Scheier) p350
-#
+# 
 # A modest 10 foldings (the default here) adds 3ms.  This makes brute forcing 10
 # times harder, while reducing an app that otherwise serves 100 reqs/s to 78 signin
 # reqs/s, an app that does 10reqs/s to 9.7 reqs/s
-#
+# 
 # More:
 # * http://www.owasp.org/index.php/Hashing_Java
 # * &quot;An Illustrated Guide to Cryptographic Hashes&quot;:http://www.unixwiz.net/techtips/iguide-crypto-hashes.html
 
-REST_AUTH_DIGEST_STRETCHES = 10
\ No newline at end of file
+REST_AUTH_DIGEST_STRETCHES = 10</diff>
      <filename>config/initializers/site_keys.rb</filename>
    </modified>
    <modified>
      <diff>@@ -31,7 +31,7 @@ module AuthenticatedSystem
     #    current_user.login != &quot;bob&quot;
     #  end
     #
-    def authorized?(action=nil, resource=nil, *args)
+    def authorized?(action = action_name, resource = nil)
       logged_in?
     end
 
@@ -68,8 +68,10 @@ module AuthenticatedSystem
           redirect_to new_session_path
         end
         # format.any doesn't work in rails version &lt; http://dev.rubyonrails.org/changeset/8987
-        # you may want to change format.any to e.g. format.any(:js, :xml)
-        format.any do
+        # Add any other API formats here.  (Some browsers, notably IE6, send Accept: */* and trigger 
+        # the 'format.any' block incorrectly. See http://bit.ly/ie6_borken or http://bit.ly/ie6_borken2
+        # for a workaround.)
+        format.any(:json, :xml) do
           request_http_basic_authentication 'Web Password'
         end
       end
@@ -164,7 +166,7 @@ module AuthenticatedSystem
     end
     
     # Refresh the cookie auth token if it exists, create it otherwise
-    def handle_remember_cookie! new_cookie_flag
+    def handle_remember_cookie!(new_cookie_flag)
       return unless @current_user
       case
       when valid_remember_cookie? then @current_user.refresh_token # keeping same expiry date</diff>
      <filename>lib/authenticated_system.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,19 +4,13 @@ require 'sessions_controller'
 # Re-raise errors caught by the controller.
 class SessionsController; def rescue_action(e) raise e end; end
 
-class SessionsControllerTest &lt; Test::Unit::TestCase
+class SessionsControllerTest &lt; ActionController::TestCase
   # Be sure to include AuthenticatedTestHelper in test/test_helper.rb instead
   # Then, you can remove it from this and the units test.
   include AuthenticatedTestHelper
 
   fixtures :users
 
-  def setup
-    @controller = SessionsController.new
-    @request    = ActionController::TestRequest.new
-    @response   = ActionController::TestResponse.new
-  end
-
   def test_should_login_and_redirect
     post :create, :login =&gt; 'quentin', :password =&gt; 'monkey'
     assert session[:user_id]</diff>
      <filename>test/functional/sessions_controller_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,19 +4,13 @@ require 'users_controller'
 # Re-raise errors caught by the controller.
 class UsersController; def rescue_action(e) raise e end; end
 
-class UsersControllerTest &lt; Test::Unit::TestCase
+class UsersControllerTest &lt; ActionController::TestCase
   # Be sure to include AuthenticatedTestHelper in test/test_helper.rb instead
   # Then, you can remove it from this and the units test.
   include AuthenticatedTestHelper
 
   fixtures :users
 
-  def setup
-    @controller = UsersController.new
-    @request    = ActionController::TestRequest.new
-    @response   = ActionController::TestResponse.new
-  end
-
   def test_should_allow_signup
     assert_difference 'User.count' do
       create_user</diff>
      <filename>test/functional/users_controller_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,6 @@
 require File.dirname(__FILE__) + '/../test_helper'
 
-class UserTest &lt; Test::Unit::TestCase
+class UserTest &lt; ActiveSupport::TestCase
   # Be sure to include AuthenticatedTestHelper in test/test_helper.rb instead.
   # Then, you can remove it from this and the functional test.
   include AuthenticatedTestHelper</diff>
      <filename>test/unit/user_test.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>db/migrate/005_create_users.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>cfd7d26f7e106f26f475ecccf057d11017d2c231</id>
    </parent>
  </parents>
  <author>
    <name>rodrigo franco (caffo)</name>
    <email>caffeine@gmail.com</email>
  </author>
  <url>http://github.com/caffo/colorplan/commit/84a53b449d35009ccdef3dd0ad9f1a5d47b9be8b</url>
  <id>84a53b449d35009ccdef3dd0ad9f1a5d47b9be8b</id>
  <committed-date>2009-01-14T17:47:16-08:00</committed-date>
  <authored-date>2009-01-14T17:47:16-08:00</authored-date>
  <message>User system refactored</message>
  <tree>e382291745db2638ef16f59a1b8d624fa8057175</tree>
  <committer>
    <name>rodrigo franco (caffo)</name>
    <email>caffeine@gmail.com</email>
  </committer>
</commit>
