Commit 46ad09bf70400eeebab5495ee6a5ded4da86012e
1 parent
5101ff7b
Exists in
spb-stable
and in
3 other branches
code refactor as per standards
Showing
3 changed files
with
9 additions
and
6 deletions
Show diff stats
app/controllers/profiles/keys_controller.rb
@@ -34,14 +34,17 @@ class Profiles::KeysController < ApplicationController | @@ -34,14 +34,17 @@ class Profiles::KeysController < ApplicationController | ||
34 | end | 34 | end |
35 | end | 35 | end |
36 | 36 | ||
37 | - #get all keys of a user(params[:username]) in a text format | ||
38 | - #helpful for sysadmins to put in respective servers | 37 | + # Get all keys of a user(params[:username]) in a text format |
38 | + # Helpful for sysadmins to put in respective servers | ||
39 | def get_keys | 39 | def get_keys |
40 | if params[:username].present? | 40 | if params[:username].present? |
41 | begin | 41 | begin |
42 | user = User.find_by_username(params[:username]) | 42 | user = User.find_by_username(params[:username]) |
43 | - user.present? ? (render :text => user.all_ssh_keys.join('\n')) : | ||
44 | - (render_404 and return) | 43 | + if user.present? |
44 | + render text: user.all_ssh_keys.join('\n') | ||
45 | + else | ||
46 | + render_404 and return | ||
47 | + end | ||
45 | rescue => e | 48 | rescue => e |
46 | render text: e.message | 49 | render text: e.message |
47 | end | 50 | end |
app/models/user.rb
config/routes.rb
@@ -12,7 +12,7 @@ Gitlab::Application.routes.draw do | @@ -12,7 +12,7 @@ Gitlab::Application.routes.draw do | ||
12 | API::API.logger Rails.logger | 12 | API::API.logger Rails.logger |
13 | mount API::API => '/api' | 13 | mount API::API => '/api' |
14 | 14 | ||
15 | - #get all keys of user | 15 | + # Get all keys of user |
16 | get ':username.keys' => 'profiles/keys#get_keys' , constraints: { username: /.*/ } | 16 | get ':username.keys' => 'profiles/keys#get_keys' , constraints: { username: /.*/ } |
17 | 17 | ||
18 | constraint = lambda { |request| request.env["warden"].authenticate? and request.env['warden'].user.admin? } | 18 | constraint = lambda { |request| request.env["warden"].authenticate? and request.env['warden'].user.admin? } |