code refactor as per standards
This commit is contained in:
parent
5101ff7bec
commit
46ad09bf70
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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? }
|
||||
|
|
Loading…
Reference in New Issue