BigW Consortium Gitlab

application_controller.rb 777 Bytes
Newer Older
1
class Projects::ApplicationController < ApplicationController
2 3
  before_action :project
  before_action :repository
4
  layout 'project'
5 6 7 8 9 10

  def authenticate_user!
    # Restrict access to Projects area only
    # for non-signed users
    if !current_user
      id = params[:project_id] || params[:id]
Vinnie Okada committed
11 12
      project_with_namespace = "#{params[:namespace_id]}/#{id}"
      @project = Project.find_with_namespace(project_with_namespace)
13

14
      return if @project && @project.public?
15 16 17 18 19
    end

    super
  end

20 21
  def require_branch_head
    unless @repository.branch_names.include?(@ref)
Vinnie Okada committed
22 23 24 25
      redirect_to(
        namespace_project_tree_path(@project.namespace, @project, @ref),
        notice: "This action is not allowed unless you are on top of a branch"
      )
26 27
    end
  end
28
end