incubator-heraldry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trot...@apache.org
Subject svn commit: r454440 - in /incubator/heraldry/idp/pip/trunk: app/controllers/server_controller.rb app/helpers/account_helper.rb app/models/user.rb test/unit/user_test.rb
Date Mon, 09 Oct 2006 17:54:20 GMT
Author: trotter
Date: Mon Oct  9 10:54:19 2006
New Revision: 454440

URL: http://svn.apache.org/viewvc?view=rev&rev=454440
Log:
* Adding dashes to user logins.

Modified:
    incubator/heraldry/idp/pip/trunk/app/controllers/server_controller.rb
    incubator/heraldry/idp/pip/trunk/app/helpers/account_helper.rb
    incubator/heraldry/idp/pip/trunk/app/models/user.rb
    incubator/heraldry/idp/pip/trunk/test/unit/user_test.rb

Modified: incubator/heraldry/idp/pip/trunk/app/controllers/server_controller.rb
URL: http://svn.apache.org/viewvc/incubator/heraldry/idp/pip/trunk/app/controllers/server_controller.rb?view=diff&rev=454440&r1=454439&r2=454440
==============================================================================
--- incubator/heraldry/idp/pip/trunk/app/controllers/server_controller.rb (original)
+++ incubator/heraldry/idp/pip/trunk/app/controllers/server_controller.rb Mon Oct  9 10:54:19
2006
@@ -286,7 +286,7 @@
   #--
   # TODO: Verify that this isn't the same as a method in ApplicationController
   def extract_identity(uri)
-    return $1.downcase if uri =~ %r[/user/([a-zA-Z_1-9]*)] || uri =~ %r[://([a-zA-Z_1-9]*)?\.#{AppConfig.host(request.host)}]
|| uri =~ %r[://(.*?)/?$]
+    return $1.downcase if uri =~ %r[/user/([a-zA-Z_1-9-]*)] || uri =~ %r[://([a-zA-Z_1-9-]*)?\.#{AppConfig.host(request.host)}]
|| uri =~ %r[://(.*?)/?$]
     return nil
   end
   

Modified: incubator/heraldry/idp/pip/trunk/app/helpers/account_helper.rb
URL: http://svn.apache.org/viewvc/incubator/heraldry/idp/pip/trunk/app/helpers/account_helper.rb?view=diff&rev=454440&r1=454439&r2=454440
==============================================================================
--- incubator/heraldry/idp/pip/trunk/app/helpers/account_helper.rb (original)
+++ incubator/heraldry/idp/pip/trunk/app/helpers/account_helper.rb Mon Oct  9 10:54:19 2006
@@ -51,7 +51,7 @@
   end
 
   def get_login_from_url(url)
-    if (url =~ %r[http://((\w+\.){0,2}\w+)\.#{host_with_port}]) || (url =~ %r[/user/((\w+\.){0,2}\w+)])

+    if (url =~ %r[http://(([\w-]+\.){0,2}[\w-]+)\.#{host_with_port}]) || (url =~ %r[/user/(([\w-]+\.){0,2}[\w-]+)])

       $1.gsub(/_/, '.')
     elsif (login = get_login_from_domain(url))
       login
@@ -61,7 +61,7 @@
   end
 
   def get_login_from_domain(url)
-    url =~ %r[http://((\w+\.){0,2}\w+)]
+    url =~ %r[http://(([\w-]+\.){0,2}[\w-]+)]
     login = $1
     if url && APP_CONFIG[:restricted_names].include?(login.split('.').last)
       login

Modified: incubator/heraldry/idp/pip/trunk/app/models/user.rb
URL: http://svn.apache.org/viewvc/incubator/heraldry/idp/pip/trunk/app/models/user.rb?view=diff&rev=454440&r1=454439&r2=454440
==============================================================================
--- incubator/heraldry/idp/pip/trunk/app/models/user.rb (original)
+++ incubator/heraldry/idp/pip/trunk/app/models/user.rb Mon Oct  9 10:54:19 2006
@@ -56,8 +56,8 @@
   validates_uniqueness_of   :login, :email
   before_save :encrypt_password
   before_create :make_activation_code
-  validates_format_of       :login, :with => /^([a-z0-9]+\.){0,2}[a-z0-9]+$/i, :on =>
:create,
-                            :message => 'can only contain letters, numbers, and two dots.',
+  validates_format_of       :login, :with => /^([a-z0-9-]+\.){0,2}[a-z0-9-]+$/i, :on =>
:create,
+                            :message => 'can only contain letters, hyphen, digits, and
two dots.',
                             :if => Proc.new {|user| user.login && !user.login.empty?
}
   validates_format_of       :email, :with => /^[a-z0-9.+-_]+@([a-z0-9-]+(.[a-z0-9-]+)+)$/i,
:on => :create,
                             :message => 'must be a proper email address.',

Modified: incubator/heraldry/idp/pip/trunk/test/unit/user_test.rb
URL: http://svn.apache.org/viewvc/incubator/heraldry/idp/pip/trunk/test/unit/user_test.rb?view=diff&rev=454440&r1=454439&r2=454440
==============================================================================
--- incubator/heraldry/idp/pip/trunk/test/unit/user_test.rb (original)
+++ incubator/heraldry/idp/pip/trunk/test/unit/user_test.rb Mon Oct  9 10:54:19 2006
@@ -47,6 +47,11 @@
     end
   end
 
+  def test_should_allow_login_with_dash
+    u = create_user(:login => 'quentin-jones')
+    assert u.errors.on(:login)
+  end
+
   def test_should_allow_login_with_two_dots
     u = create_user(:login => 'quentin.mark.jones')
     assert u.valid?, u.errors.full_messages.join("\n")



Mime
View raw message