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

33 lines
821 B
Ruby
Raw Normal View History

2013-02-28 17:02:14 +00:00
class Users::UsersController < Users::BaseController
2015-03-04 23:19:19 +00:00
skip_before_action :authenticate_user!, only: [:allowed, :check, :discover]
skip_after_action :verify_authorized
2015-03-04 23:19:19 +00:00
before_action :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]
2015-03-14 22:10:04 +00:00
pp = ProjectPolicy.new(@user, project)
can = case params[:action_type]
when 'git-upload-pack'
pp.read?
when 'git-receive-pack'
pp.write?
end
render inline: (!@user.access_locked? && can).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