diff options
-rw-r--r-- | app/controllers/profiles/keys_controller.rb | 11 | ||||
-rw-r--r-- | app/models/user.rb | 2 | ||||
-rw-r--r-- | config/routes.rb | 2 |
3 files changed, 9 insertions, 6 deletions
diff --git a/app/controllers/profiles/keys_controller.rb b/app/controllers/profiles/keys_controller.rb index 7c97987d006..e8237a1f227 100644 --- a/app/controllers/profiles/keys_controller.rb +++ b/app/controllers/profiles/keys_controller.rb @@ -34,14 +34,17 @@ class Profiles::KeysController < ApplicationController end end - #get all keys of a user(params[:username]) in a text format - #helpful for sysadmins to put in respective servers + # Get all keys of a user(params[:username]) in a text format + # Helpful 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 diff --git a/app/models/user.rb b/app/models/user.rb index 2a58692375d..10f21d23506 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/config/routes.rb b/config/routes.rb index 1cc6242c623..8c66ad741f9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,7 +12,7 @@ Gitlab::Application.routes.draw do API::API.logger Rails.logger mount API::API => '/api' - #get all keys of user + # Get 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? } |