application_controller.rb 754 Bytes
Newer Older
1
class Projects::ApplicationController < ApplicationController
2 3
  before_filter :project
  before_filter :repository
4 5 6 7 8 9 10 11 12
  layout :determine_layout

  def authenticate_user!
    # Restrict access to Projects area only
    # for non-signed users
    if !current_user
      id = params[:project_id] || params[:id]
      @project = Project.find_with_namespace(id)

13
      return if @project && @project.public?
14 15 16 17 18 19 20 21 22
    end

    super
  end

  def determine_layout
    if current_user
      'projects'
    else
23
      'public_projects'
24 25
    end
  end
26 27 28 29 30 31

  def require_branch_head
    unless @repository.branch_names.include?(@ref)
      redirect_to project_tree_path(@project, @ref), notice: "This action is not allowed unless you are on top of a branch"
    end
  end
32
end