debian-mirror-gitlab/app/controllers/projects/application_controller.rb

37 lines
893 B
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
class Projects::ApplicationController < ApplicationController
before_filter :project
before_filter :repository
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]
2015-04-26 12:48:37 +05:30
project_with_namespace = "#{params[:namespace_id]}/#{id}"
@project = Project.find_with_namespace(project_with_namespace)
2014-09-02 18:07:02 +05:30
return if @project && @project.public?
end
super
end
def determine_layout
if current_user
'projects'
else
'public_projects'
end
end
def require_branch_head
unless @repository.branch_names.include?(@ref)
2015-04-26 12:48:37 +05:30
redirect_to(
namespace_project_tree_path(@project.namespace, @project, @ref),
notice: "This action is not allowed unless you are on top of a branch"
)
2014-09-02 18:07:02 +05:30
end
end
end