Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Privacy
Imprint
Contact
Login methods
Sign in
Toggle navigation
Menu
Open sidebar
projects.thm.de
GitLab
Commits
46ad09bf
Commit
46ad09bf
authored
Feb 11, 2014
by
GitLab
Browse files
code refactor as per standards
parent
5101ff7b
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/controllers/profiles/keys_controller.rb
View file @
46ad09bf
...
...
@@ -34,14 +34,17 @@ def destroy
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
...
...
app/models/user.rb
View file @
46ad09bf
...
...
@@ -437,6 +437,6 @@ def short_website_url
end
def
all_ssh_keys
keys
.
collect
{
|
x
|
x
.
key
}.
join
(
"
\n
"
)
keys
.
map
(
&
:key
)
end
end
config/routes.rb
View file @
46ad09bf
...
...
@@ -12,7 +12,7 @@
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?
}
...
...
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