Commit 46ad09bf by GitLab

code refactor as per standards

parent 5101ff7b
......@@ -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? }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment