gitlab-org--gitlab-foss/app/controllers/projects/avatars_controller.rb

27 lines
552 B
Ruby
Raw Normal View History

class Projects::AvatarsController < Projects::ApplicationController
include BlobHelper
2016-03-20 20:03:53 +00:00
before_action :authorize_admin_project!, only: [:destroy]
def show
@blob = @repository.blob_at_branch(@repository.root_ref, @project.avatar_in_git)
if @blob
headers['X-Content-Type-Options'] = 'nosniff'
2016-03-07 13:27:53 +00:00
return if cached_blob?
send_git_blob @repository, @blob
else
2015-10-09 17:07:29 +00:00
render_404
end
end
def destroy
@project.remove_avatar!
@project.save
redirect_to edit_project_path(@project), status: 302
end
end