[PATCH conductor] BZ-863465 username can contain only characters and numbers

Tomáš Hrčka thrcka at redhat.com
Mon Oct 8 12:00:14 UTC 2012


https://bugzilla.redhat.com/show_bug.cgi?id=863465
---
 src/app/models/user.rb    | 1 +
 src/config/locales/en.yml | 1 +
 2 files changed, 2 insertions(+)

diff --git a/src/app/models/user.rb b/src/app/models/user.rb
index 5db8e95..e4b7854 100644
--- a/src/app/models/user.rb
+++ b/src/app/models/user.rb
@@ -84,6 +84,7 @@ class User < ActiveRecord::Base
   validates_length_of :last_name,  :maximum => 255, :allow_blank => true
   validates_uniqueness_of :username
   validates_length_of :username, :within => 1..100, :allow_blank => false
+  validates_format_of :username, :with => /[a-z0-9A-Z]/, :message => I18n.t("users.flash.warning.invalid_username")
   validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i, :unless => Proc.new {|u| u.email.nil?}
   validates_confirmation_of :password, :if => Proc.new {|u| u.check_password?}
   validates_length_of :password, :within => 4..255, :if => Proc.new {|u| u.check_password?}
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index e052f91..6b03cf5 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -100,6 +100,7 @@ en:
       warning:
         not_delete: 'Cannot delete: %{reason}'
         not_delete_same_user: "Cannot delete %{username} : You are logged in as this user"
+        invalid_username: 'should use only letters and numbers.'
     preset_filters:
       all_users: "All Users"
       name_starts_with_A: "Name starts with A"
-- 
1.7.11.4




More information about the aeolus-devel mailing list