<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -10,16 +10,16 @@ class &lt;%= class_name %&gt; &lt; ActiveRecord::Base
   include Authorization::StatefulRoles&lt;% end %&gt;
   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
 
   &lt;% if options[:include_activation] &amp;&amp; !options[:stateful] %&gt;before_create :make_activation_code &lt;% end %&gt;
 
@@ -54,12 +54,21 @@ class &lt;%= class_name %&gt; &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 = &lt;% if    options[:stateful]           %&gt;find_in_state :first, :active, :conditions =&gt; {:login =&gt; login}&lt;%
            elsif options[:include_activation] %&gt;find :first, :conditions =&gt; ['login = ? and activated_at IS NOT NULL', login]&lt;%
            else %&gt;find_by_login(login)&lt;% end %&gt; # need to get the salt
     u &amp;&amp; u.authenticated?(password) ? u : nil
   end
 
+  def login=(value)
+    write_attribute :login, (value ? value.downcase : nil)
+  end
+
+  def email=(value)
+    write_attribute :email, (value ? value.downcase : nil)
+  end
+
   protected
     
 &lt;% if options[:include_activation] -%&gt;</diff>
      <filename>generators/authenticated/templates/model.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,24 +1,22 @@
 module Authentication
-  unless defined? CONSTANTS_DEFINED
-    # Uncomment to suit
-    RE_LOGIN_OK     = /\A\w[\w\.\-_@]+\z/                     # ASCII, strict
-    # RE_LOGIN_OK   = /\A[[:alnum:]][[:alnum:]\.\-_@]+\z/     # Unicode, strict
-    # RE_LOGIN_OK   = /\A[^[:cntrl:]\\&lt;&gt;\/&amp;]*\z/              # Unicode, permissive
-    MSG_LOGIN_BAD   = &quot;use only letters, numbers, and .-_@ please.&quot;
-
-    RE_NAME_OK      = /\A[^[:cntrl:]\\&lt;&gt;\/&amp;]*\z/              # Unicode, permissive
-    MSG_NAME_BAD    = &quot;avoid non-printing characters and \\&amp;gt;&amp;lt;&amp;amp;/ please.&quot;
-
-    # This is purposefully imperfect -- it's just a check for bogus input. See
-    # http://www.regular-expressions.info/email.html
-    RE_EMAIL_NAME   = '[\w\.%\+\-]+'                          # what you actually see in practice
-    #RE_EMAIL_NAME   = '0-9A-Z!#\$%\&amp;\'\*\+_/=\?^\-`\{|\}~\.' # technically allowed by RFC-2822
-    RE_DOMAIN_HEAD  = '(?:[A-Z0-9\-]+\.)+'
-    RE_DOMAIN_TLD   = '(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|jobs|museum)'
-    RE_EMAIL_OK     = /\A#{RE_EMAIL_NAME}@#{RE_DOMAIN_HEAD}#{RE_DOMAIN_TLD}\z/i
-    MSG_EMAIL_BAD   = &quot;should look like an email address.&quot;
-    CONSTANTS_DEFINED = true # sorry for the C idiom
-  end
+  mattr_accessor :login_regex, :bad_login_message, 
+    :name_regex, :bad_name_message,
+    :email_name_regex, :domain_head_regex, :domain_tld_regex, :email_regex, :bad_email_message
+
+  self.login_regex       = /\A\w[\w\.\-_@]+\z/                     # ASCII, strict
+  # self.login_regex       = /\A[[:alnum:]][[:alnum:]\.\-_@]+\z/     # Unicode, strict
+  # self.login_regex       = /\A[^[:cntrl:]\\&lt;&gt;\/&amp;]*\z/              # Unicode, permissive
+
+  self.bad_login_message = &quot;use only letters, numbers, and .-_@ please.&quot;.freeze
+
+  self.name_regex        = /\A[^[:cntrl:]\\&lt;&gt;\/&amp;]*\z/              # Unicode, permissive
+  self.bad_name_message  = &quot;avoid non-printing characters and \\&amp;gt;&amp;lt;&amp;amp;/ please.&quot;.freeze
+
+  self.email_name_regex  = '[\w\.%\+\-]+'.freeze
+  self.domain_head_regex = '(?:[A-Z0-9\-]+\.)+'.freeze
+  self.domain_tld_regex  = '(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|jobs|museum)'.freeze
+  self.email_regex       = /\A#{email_name_regex}@#{domain_head_regex}#{domain_tld_regex}\z/i
+  self.bad_email_message = &quot;should look like an email address.&quot;.freeze
 
   def self.included(recipient)
     recipient.extend(ModelClassMethods)</diff>
      <filename>lib/authentication.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>e2c59cad93265d067d808d092089a9d4597d7fcd</id>
    </parent>
  </parents>
  <author>
    <name>rick</name>
    <email>technoweenie@gmail.com</email>
  </author>
  <url>http://github.com/quirkey/restful-authentication/commit/20881213f76c8c8e817e18a7b276555922bb69f5</url>
  <id>20881213f76c8c8e817e18a7b276555922bb69f5</id>
  <committed-date>2008-08-25T09:51:32-07:00</committed-date>
  <authored-date>2008-08-25T09:51:32-07:00</authored-date>
  <message>change Authentication constants to mattr_accessors to allow them to be customized in apps.  also, force logins and emails to be downcased (be nice to your db)</message>
  <tree>70b08ded9abf6a130047dc98d7f7c96487951708</tree>
  <committer>
    <name>rick</name>
    <email>technoweenie@gmail.com</email>
  </committer>
</commit>
