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 | 34 | end |
35 | 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 | 39 | def get_keys |
40 | 40 | if params[:username].present? |
41 | 41 | begin |
42 | 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 | 48 | rescue => e |
46 | 49 | render text: e.message |
47 | 50 | end | ... | ... |
app/models/user.rb
config/routes.rb
... | ... | @@ -12,7 +12,7 @@ Gitlab::Application.routes.draw do |
12 | 12 | API::API.logger Rails.logger |
13 | 13 | mount API::API => '/api' |
14 | 14 | |
15 | - #get all keys of user | |
15 | + # Get all keys of user | |
16 | 16 | get ':username.keys' => 'profiles/keys#get_keys' , constraints: { username: /.*/ } |
17 | 17 | |
18 | 18 | constraint = lambda { |request| request.env["warden"].authenticate? and request.env['warden'].user.admin? } | ... | ... |