Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app/roles
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2012-09-04 08:04:36 +0400
committerRobert Speicher <rspeicher@gmail.com>2012-09-04 08:20:17 +0400
commitd29827433d77b9f9353fcae396ca321dd9016771 (patch)
tree0f963d69cb52539d7937af6bd772437380db7789 /app/roles
parentb44e9a08d5c0e012d645e75a321c6ea299b4bea1 (diff)
Update User#identifier to conform to Gitolite 2.x's user pattern
Also modifies the specs a bit because I can't help myself. Closes #480
Diffstat (limited to 'app/roles')
-rw-r--r--app/roles/account.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/app/roles/account.rb b/app/roles/account.rb
index 63a9b5c51bf..b8c445a3d58 100644
--- a/app/roles/account.rb
+++ b/app/roles/account.rb
@@ -1,6 +1,13 @@
-module Account
+module Account
+ # Returns a string for use as a Gitolite user identifier
+ #
+ # Note that Gitolite 2.x requires the following pattern for users:
+ #
+ # ^@?[0-9a-zA-Z][0-9a-zA-Z._\@+-]*$
def identifier
- email.gsub /[^[:alnum:]]/, "_"
+ # Replace non-word chars with underscores, then make sure it starts with
+ # valid chars
+ email.gsub(/\W/, '_').gsub(/\A([\W\_])+/, '')
end
def is_admin?