... | ... |
@@ -1,9 +1,10 @@ |
1 | 1 |
<% |
2 |
- my $user = param('user'); |
|
2 |
+ my $user_id = param('user'); |
|
3 | 3 |
|
4 |
- warn param('user.keys'); |
|
5 |
- |
|
6 |
- my $keys = app->dbi->model('ssh_public_key')->select(where => {user_id => $user})->all; |
|
4 |
+ my $keys = app->dbi->model('ssh_public_key')->select( |
|
5 |
+ where => {'__user.id' => $user_id}, |
|
6 |
+ append => 'order by title' |
|
7 |
+ )->all; |
|
7 | 8 |
my $keys_str = ''; |
8 | 9 |
for my $key (@$keys) { |
9 | 10 |
$keys_str .= "$key->{key}\n"; |
... | ... |
@@ -4,10 +4,10 @@ |
4 | 4 |
|
5 | 5 |
# Parameters |
6 | 6 |
my $op = param('op') || ''; |
7 |
- my $user = param('user') || ''; |
|
7 |
+ my $user_id = param('user') || ''; |
|
8 | 8 |
|
9 | 9 |
# Authentication |
10 |
- unless ($api->logined($user)) { |
|
10 |
+ unless ($api->logined($user_id)) { |
|
11 | 11 |
$self->redirect_to('/'); |
12 | 12 |
return; |
13 | 13 |
} |
... | ... |
@@ -49,6 +49,9 @@ |
49 | 49 |
if (!(defined $original_key && length $original_key)) { |
50 | 50 |
$validation->add_failed(key => 'key is empty'); |
51 | 51 |
} |
52 |
+ elsif (length $original_key > 2000) { |
|
53 |
+ $validation->add_failed(key => 'key is too long'); |
|
54 |
+ } |
|
52 | 55 |
else { |
53 | 56 |
my $type; |
54 | 57 |
my $original_key_edit; |
... | ... |
@@ -99,8 +102,9 @@ |
99 | 102 |
|
100 | 103 |
# Register ssh key |
101 | 104 |
if ($validation->is_valid) { |
105 |
+ my $session_user_row_id = $api->session_user_row_id; |
|
102 | 106 |
my $p = { |
103 |
- user_id => $user, |
|
107 |
+ user => $session_user_row_id, |
|
104 | 108 |
title => $title, |
105 | 109 |
key => $key |
106 | 110 |
}; |
... | ... |
@@ -128,6 +132,7 @@ |
128 | 132 |
# Delete ssh public key |
129 | 133 |
elsif ($op eq 'delete') { |
130 | 134 |
my $row_id = param('row-id'); |
135 |
+ |
|
131 | 136 |
eval { |
132 | 137 |
app->dbi->connector->txn(sub { |
133 | 138 |
app->dbi->model('ssh_public_key')->delete(where => {row_id => $row_id}); |
... | ... |
@@ -146,7 +151,13 @@ |
146 | 151 |
} |
147 | 152 |
} |
148 | 153 |
|
149 |
- my $keys = app->dbi->model('ssh_public_key')->select(where => {user_id => $user})->all; |
|
154 |
+ my $keys = app->dbi->model('ssh_public_key')->select( |
|
155 |
+ { |
|
156 |
+ __MY__ => '*' |
|
157 |
+ }, |
|
158 |
+ where => {'__user.id' => $user_id}, |
|
159 |
+ append => 'order by title' |
|
160 |
+ )->all; |
|
150 | 161 |
%> |
151 | 162 |
|
152 | 163 |
% layout 'common', title => 'SSH keys'; |
... | ... |
@@ -158,10 +169,10 @@ |
158 | 169 |
<div class="left"> |
159 | 170 |
<ul> |
160 | 171 |
<li> |
161 |
- <a href="<%= url_for("/$user/_settings") %>">Profile</a> |
|
172 |
+ <a href="<%= url_for("/$user_id/_settings") %>">Profile</a> |
|
162 | 173 |
</li> |
163 | 174 |
<li class="active"> |
164 |
- <a href="<%= url_for("/$user/_settings/ssh") %>">SSH keys</a> |
|
175 |
+ <a href="<%= url_for("/$user_id/_settings/ssh") %>">SSH keys</a> |
|
165 | 176 |
</li> |
166 | 177 |
</ul> |
167 | 178 |
</div> |
... | ... |
@@ -172,7 +183,7 @@ |
172 | 183 |
<div class="user-settings-container ssh-keys"> |
173 | 184 |
<div> |
174 | 185 |
<div> |
175 |
- <span>SSH Keys</span> (<a href="<%= url_for("/$user.keys") %>">see</a>) |
|
186 |
+ <span>SSH Keys</span> (<a href="<%= url_for("/$user_id.keys") %>">see</a>) |
|
176 | 187 |
</div> |
177 | 188 |
</div> |
178 | 189 |
<div> |