33 lines
927 B
Ruby
33 lines
927 B
Ruby
# -*- encoding : utf-8 -*-
|
|
class Users::UsersController < Users::BaseController
|
|
skip_before_filter :authenticate_user!, :only => [:allowed, :check, :discover]
|
|
before_filter :find_user_by_key, :only => [:allowed, :discover]
|
|
|
|
def allowed
|
|
owner_name, project_name = params[:project].split '/'
|
|
project = Project.find_by_owner_and_name!(owner_name, project_name ? project_name : '!')
|
|
action = case params[:action_type]
|
|
when 'git-upload-pack'
|
|
then :read
|
|
when 'git-receive-pack'
|
|
then :write
|
|
end
|
|
render :inline => (!@user.access_locked? && Ability.new(@user).can?(action, project)).to_s
|
|
end
|
|
|
|
def check
|
|
render :nothing => true
|
|
end
|
|
|
|
def discover
|
|
render :json => {:name => @user.name}.to_json
|
|
end
|
|
|
|
protected
|
|
|
|
def find_user_by_key
|
|
key = SshKey.find(params[:key_id])
|
|
@user = key.user
|
|
end
|
|
end
|