summaryrefslogtreecommitdiff
path: root/app/controllers/projects/avatars_controller.rb
blob: 53fdc5843b5cd9dd52b06f3c50d282003ec300f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class Projects::AvatarsController < Projects::ApplicationController
  include BlobHelper

  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'

      return if cached_blob?

      send_git_blob @repository, @blob
    else
      render_404
    end
  end

  def destroy
    @project.remove_avatar!

    @project.save

    redirect_to edit_project_path(@project, anchor: 'js-general-project-settings'), status: :found
  end
end