Commit b698094d4dcd1558bfcc1611d3572297dd11ae1e
1 parent
ed3f4408
Exists in
master
and in
4 other branches
Update post-receive worker to use correct identifier
Showing
2 changed files
with
12 additions
and
11 deletions
Show diff stats
app/workers/post_receive.rb
... | ... | @@ -21,14 +21,18 @@ class PostReceive |
21 | 21 | return false |
22 | 22 | end |
23 | 23 | |
24 | - # Ignore push from non-gitlab users | |
25 | - user = if identifier.nil? | |
26 | - raise identifier.inspect | |
24 | + user = if identifier.blank? | |
25 | + # Local push from gitlab | |
27 | 26 | email = project.repository.commit(newrev).author.email rescue nil |
28 | 27 | User.find_by_email(email) if email |
29 | - elsif /^[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}$/.match(identifier) | |
30 | - User.find_by_email(identifier) | |
31 | - elsif identifier =~ /key/ | |
28 | + | |
29 | + elsif identifier =~ /\Auser-\d+\Z/ | |
30 | + # git push over http | |
31 | + user_id = identifier.gsub("user-", "") | |
32 | + User.find_by_id(user_id) | |
33 | + | |
34 | + elsif identifier =~ /\Akey-\d+\Z/ | |
35 | + # git push over ssh | |
32 | 36 | key_id = identifier.gsub("key-", "") |
33 | 37 | Key.find_by_id(key_id).try(:user) |
34 | 38 | end | ... | ... |
lib/gitlab/backend/grack_auth.rb
... | ... | @@ -7,9 +7,6 @@ module Grack |
7 | 7 | @request = Rack::Request.new(env) |
8 | 8 | @auth = Request.new(env) |
9 | 9 | |
10 | - # Pass Gitolite update hook | |
11 | - ENV['GL_BYPASS_UPDATE_HOOK'] = "true" | |
12 | - | |
13 | 10 | # Need this patch due to the rails mount |
14 | 11 | @env['PATH_INFO'] = @request.path |
15 | 12 | @env['SCRIPT_NAME'] = "" |
... | ... | @@ -35,8 +32,8 @@ module Grack |
35 | 32 | self.user = User.find_by_email(login) || User.find_by_username(login) |
36 | 33 | return false unless user.try(:valid_password?, password) |
37 | 34 | |
38 | - # Set GL_USER env variable | |
39 | - ENV['GL_USER'] = user.email | |
35 | + # Set GL_ID env variable | |
36 | + ENV['GL_ID'] = "user-#{user.id}" | |
40 | 37 | end |
41 | 38 | |
42 | 39 | # Git upload and receive | ... | ... |