Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
46ad09bf
Commit
46ad09bf
authored
10 years ago
by
GitLab
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code refactor as per standards
parent
5101ff7b
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
6 deletions
+9
-6
app/controllers/profiles/keys_controller.rb
app/controllers/profiles/keys_controller.rb
+7
-4
app/models/user.rb
app/models/user.rb
+1
-1
config/routes.rb
config/routes.rb
+1
-1
No files found.
app/controllers/profiles/keys_controller.rb
View file @
46ad09bf
...
...
@@ -34,14 +34,17 @@ class Profiles::KeysController < ApplicationController
end
end
#
g
et all keys of a user(params[:username]) in a text format
#
h
elpful for sysadmins to put in respective servers
#
G
et all keys of a user(params[:username]) in a text format
#
H
elpful for sysadmins to put in respective servers
def
get_keys
if
params
[
:username
].
present?
begin
user
=
User
.
find_by_username
(
params
[
:username
])
user
.
present?
?
(
render
:text
=>
user
.
all_ssh_keys
.
join
(
'\n'
))
:
(
render_404
and
return
)
if
user
.
present?
render
text:
user
.
all_ssh_keys
.
join
(
'\n'
)
else
render_404
and
return
end
rescue
=>
e
render
text:
e
.
message
end
...
...
This diff is collapsed.
Click to expand it.
app/models/user.rb
View file @
46ad09bf
...
...
@@ -437,6 +437,6 @@ class User < ActiveRecord::Base
end
def
all_ssh_keys
keys
.
collect
{
|
x
|
x
.
key
}.
join
(
"
\n
"
)
keys
.
map
(
&
:key
)
end
end
This diff is collapsed.
Click to expand it.
config/routes.rb
View file @
46ad09bf
...
...
@@ -12,7 +12,7 @@ Gitlab::Application.routes.draw do
API
::
API
.
logger
Rails
.
logger
mount
API
::
API
=>
'/api'
#
g
et all keys of user
#
G
et all keys of user
get
':username.keys'
=>
'profiles/keys#get_keys'
,
constraints:
{
username:
/.*/
}
constraint
=
lambda
{
|
request
|
request
.
env
[
"warden"
].
authenticate?
and
request
.
env
[
'warden'
].
user
.
admin?
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment