... | ... |
@@ -43,12 +43,12 @@ sub rep_home { |
43 | 43 |
} |
44 | 44 |
|
45 | 45 |
sub rep_info { |
46 |
- my ($self, $user, $project) = @_; |
|
46 |
+ my ($self, $user_id, $project_id) = @_; |
|
47 | 47 |
|
48 | 48 |
my $info = {}; |
49 |
- $info->{user} = $user; |
|
50 |
- $info->{project} = $project; |
|
51 |
- $info->{git_dir} = $self->rep_home . "/$user/$project.git"; |
|
49 |
+ $info->{user} = $user_id; |
|
50 |
+ $info->{project} = $project_id; |
|
51 |
+ $info->{git_dir} = $self->rep_home . "/$user_id/$project_id.git"; |
|
52 | 52 |
|
53 | 53 |
return $info; |
54 | 54 |
} |
... | ... |
@@ -62,13 +62,13 @@ sub work_rep_home { |
62 | 62 |
} |
63 | 63 |
|
64 | 64 |
sub work_rep_info { |
65 |
- my ($self, $user, $project) = @_; |
|
65 |
+ my ($self, $user_id, $project_id) = @_; |
|
66 | 66 |
|
67 | 67 |
my $info = {}; |
68 |
- $info->{user} = $user; |
|
69 |
- $info->{project} = $project; |
|
70 |
- $info->{git_dir} = $self->work_rep_home . "/$user/$project/.git"; |
|
71 |
- $info->{work_tree} = $self->work_rep_home . "/$user/$project"; |
|
68 |
+ $info->{user} = $user_id; |
|
69 |
+ $info->{project} = $project_id; |
|
70 |
+ $info->{git_dir} = $self->work_rep_home . "/$user_id/$project_id/.git"; |
|
71 |
+ $info->{work_tree} = $self->work_rep_home . "/$user_id/$project_id"; |
|
72 | 72 |
|
73 | 73 |
return $info; |
74 | 74 |
} |
... | ... |
@@ -164,8 +164,8 @@ sub startup { |
164 | 164 |
$self->dbi($dbi); |
165 | 165 |
|
166 | 166 |
# Database file permision |
167 |
- if (my $user = $self->config->{hypnotoad}{user}) { |
|
168 |
- my $uid = (getpwnam $user)[2]; |
|
167 |
+ if (my $user_id = $self->config->{hypnotoad}{user}) { |
|
168 |
+ my $uid = (getpwnam $user_id)[2]; |
|
169 | 169 |
chown $uid, -1, $db_file; |
170 | 170 |
} |
171 | 171 |
if (my $group = $self->config->{hypnotoad}{group}) { |
... | ... |
@@ -322,27 +322,27 @@ sub startup { |
322 | 322 |
my $self = shift; |
323 | 323 |
|
324 | 324 |
my $api = $self->gitprep_api; |
325 |
- my $user = $self->param('user'); |
|
326 |
- my $project = $self->param('project'); |
|
327 |
- my $private = $self->app->manager->is_private_project($user, $project); |
|
325 |
+ my $user_id = $self->param('user'); |
|
326 |
+ my $project_id = $self->param('project'); |
|
327 |
+ my $private = $self->app->manager->is_private_project($user_id, $project_id); |
|
328 | 328 |
|
329 | 329 |
# Basic auth when push request |
330 | 330 |
my $service = $self->param('service') || ''; |
331 | 331 |
if ($service eq 'git-receive-pack' || $private) { |
332 | 332 |
|
333 | 333 |
$self->basic_auth("Git Area", sub { |
334 |
- my ($auth_user, $auth_password) = @_; |
|
334 |
+ my ($auth_user_id, $auth_password) = @_; |
|
335 | 335 |
|
336 |
- if (!defined $auth_user || !length $auth_user) { |
|
336 |
+ if (!defined $auth_user_id || !length $auth_user_id) { |
|
337 | 337 |
$self->app->log->warn("Authentication: User name is empty"); |
338 | 338 |
} |
339 | 339 |
|
340 |
- $auth_user = '' unless defined $auth_user; |
|
340 |
+ $auth_user_id = '' unless defined $auth_user_id; |
|
341 | 341 |
$auth_password = '' unless defined $auth_password; |
342 | 342 |
|
343 | 343 |
my $is_valid = |
344 |
- ($user eq $auth_user || $api->is_collaborator($user, $project, $auth_user)) |
|
345 |
- && $api->check_user_and_password($auth_user, $auth_password); |
|
344 |
+ ($user_id eq $auth_user_id || $api->is_collaborator($auth_user_id, $user_id, $project_id)) |
|
345 |
+ && $api->check_user_and_password($auth_user_id, $auth_password); |
|
346 | 346 |
|
347 | 347 |
return $is_valid; |
348 | 348 |
}); |
... | ... |
@@ -356,10 +356,10 @@ sub startup { |
356 | 356 |
$r->get('/')->to(cb => sub { |
357 | 357 |
my $self = shift; |
358 | 358 |
|
359 |
- my $user = $self->param('user'); |
|
360 |
- my $project = $self->param('project'); |
|
359 |
+ my $user_id = $self->param('user'); |
|
360 |
+ my $project_id = $self->param('project'); |
|
361 | 361 |
|
362 |
- $self->redirect_to("/$user/$project"); |
|
362 |
+ $self->redirect_to("/$user_id/$project_id"); |
|
363 | 363 |
}); |
364 | 364 |
|
365 | 365 |
# /info/refs |
... | ... |
@@ -388,11 +388,11 @@ sub startup { |
388 | 388 |
my $api = $self->gitprep_api; |
389 | 389 |
|
390 | 390 |
# Private |
391 |
- my $user = $self->param('user'); |
|
392 |
- my $project = $self->param('project'); |
|
393 |
- my $private = $self->app->manager->is_private_project($user, $project); |
|
391 |
+ my $user_id = $self->param('user'); |
|
392 |
+ my $project_id = $self->param('project'); |
|
393 |
+ my $private = $self->app->manager->is_private_project($user_id, $project_id); |
|
394 | 394 |
if ($private) { |
395 |
- if ($api->can_access_private_project($user, $project)) { |
|
395 |
+ if ($api->can_access_private_project($user_id, $project_id)) { |
|
396 | 396 |
return 1; |
397 | 397 |
} |
398 | 398 |
else { |
... | ... |
@@ -507,7 +507,9 @@ sub startup { |
507 | 507 |
} |
508 | 508 |
}); |
509 | 509 |
|
510 |
- # Set auto_decompress for Smart HTTP(I don't know this reasone) |
|
510 |
+ # Set auto_decompress for Smart HTTP |
|
511 |
+ # HTTP request body of /smart-http/service is compressed. |
|
512 |
+ # If auto_decompress is not set, Smart HTTP fail. |
|
511 | 513 |
$self->hook('after_build_tx' => sub { |
512 | 514 |
my ($tx, $app) = @_; |
513 | 515 |
|
... | ... |
@@ -73,7 +73,7 @@ sub check_user_and_password { |
73 | 73 |
} |
74 | 74 |
|
75 | 75 |
sub is_collaborator { |
76 |
- my ($self, $user_id, $project_id, $collaborator_id) = @_; |
|
76 |
+ my ($self, $collaborator_id, $user_id, $project_id) = @_; |
|
77 | 77 |
|
78 | 78 |
my $user_row_id = $self->get_user_row_id($user_id); |
79 | 79 |
my $project_row_id = $self->app->dbi->model('project')->select( |
... | ... |
@@ -97,7 +97,7 @@ sub can_access_private_project { |
97 | 97 |
)->value; |
98 | 98 |
|
99 | 99 |
my $is_valid = |
100 |
- ($user_id eq $session_user_id || $self->is_collaborator($user_id, $project_id, $session_user_id)) |
|
100 |
+ ($user_id eq $session_user_id || $self->is_collaborator($session_user_id, $user_id, $project_id)) |
|
101 | 101 |
&& $self->logined; |
102 | 102 |
|
103 | 103 |
return $is_valid; |
... | ... |
@@ -56,7 +56,7 @@ if ($session_user_id eq $user_id) { |
56 | 56 |
$can_access = 1; |
57 | 57 |
} |
58 | 58 |
else { |
59 |
- $can_access = $app->gitprep_api->is_collaborator($user_id, $project_id, $session_user_id); |
|
59 |
+ $can_access = $app->gitprep_api->is_collaborator($session_user_id, $user_id, $project_id); |
|
60 | 60 |
} |
61 | 61 |
die qq|User "$session_user_id" can't access repository "$user_id/$project_id.git"\n| |
62 | 62 |
unless $can_access; |
... | ... |
@@ -7,12 +7,24 @@ |
7 | 7 |
my $project_id = param('project'); |
8 | 8 |
my $row_id = param('row_id'); |
9 | 9 |
|
10 |
+ # Session |
|
11 |
+ my $session_user_id = $api->session_user_id; |
|
12 |
+ |
|
10 | 13 |
# Repository information |
11 | 14 |
my $rep_info = app->rep_info($user_id, $project_id); |
12 | 15 |
|
13 | 16 |
# Git |
14 | 17 |
my $git = $self->app->git; |
15 | 18 |
|
19 |
+ if (lc $self->req->method eq 'post') { |
|
20 |
+ my $op = param('op'); |
|
21 |
+ |
|
22 |
+ # Access controll |
|
23 |
+ if ($op eq 'close') { |
|
24 |
+ |
|
25 |
+ } |
|
26 |
+ } |
|
27 |
+ |
|
16 | 28 |
# Pull requests |
17 | 29 |
my $pull_request = app->dbi->model('pull_request')->select( |
18 | 30 |
[ |