rosa-build/app/controllers/users/users_controller.rb

31 lines
794 B
Ruby
Raw Normal View History

2013-02-28 17:02:14 +00:00
class Users::UsersController < Users::BaseController
2014-01-21 04:51:49 +00:00
skip_before_filter :authenticate_user!, only: [:allowed, :check, :discover]
before_filter :find_user_by_key, only: [:allowed, :discover]
2013-02-28 17:02:14 +00:00
def allowed
2014-03-13 16:35:00 +00:00
project = Project.find_by_owner_and_name! params[:project]
2013-02-28 17:02:14 +00:00
action = case params[:action_type]
when 'git-upload-pack'
then :read
when 'git-receive-pack'
then :write
end
2014-01-21 04:51:49 +00:00
render inline: (!@user.access_locked? && Ability.new(@user).can?(action, project)).to_s
end
def check
2014-01-21 04:51:49 +00:00
render nothing: true
end
def discover
2014-01-21 04:51:49 +00:00
render json: {name: @user.name}.to_json
end
protected
def find_user_by_key
key = SshKey.find(params[:key_id])
@user = key.user
2013-02-28 17:02:14 +00:00
end
end