Skip to content
Snippets Groups Projects
Commit 46ad09bf authored by GitLab's avatar GitLab
Browse files

code refactor as per standards

parent 5101ff7b
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment