BigW Consortium Gitlab

avatars_controller.rb 559 Bytes
Newer Older
1
class Projects::AvatarsController < Projects::ApplicationController
2 3
  include BlobHelper

4
  before_action :authorize_admin_project!, only: [:destroy]
5 6

  def show
Jacob Vosmaer committed
7
    @blob = @repository.blob_at_branch('master', @project.avatar_in_git)
8 9
    if @blob
      headers['X-Content-Type-Options'] = 'nosniff'
Jacob Vosmaer committed
10 11 12

      return if cached_blob?

13
      send_git_blob @repository, @blob
14
    else
15
      render_404
16 17 18 19 20 21 22 23 24
    end
  end

  def destroy
    @project.remove_avatar!

    @project.save
    @project.reset_events_cache

25
    redirect_to edit_project_path(@project)
26 27
  end
end