Commit 122acb2254c94823bd7b7b64aa1bd953df5fdf66

Authored by Dmitriy Zaporozhets
1 parent 4c6224aa

fix unauth for public

app/controllers/public/projects_controller.rb
@@ -6,6 +6,6 @@ class Public::ProjectsController < ApplicationController @@ -6,6 +6,6 @@ class Public::ProjectsController < ApplicationController
6 layout 'public' 6 layout 'public'
7 7
8 def index 8 def index
9 - @projects = Project.where(public: true) 9 + @projects = Project.public
10 end 10 end
11 end 11 end
app/models/project.rb
@@ -81,6 +81,7 @@ class Project < ActiveRecord::Base @@ -81,6 +81,7 @@ class Project < ActiveRecord::Base
81 scope :sorted_by_activity, ->() { order("(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC") } 81 scope :sorted_by_activity, ->() { order("(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC") }
82 scope :personal, ->(user) { where(namespace_id: user.namespace_id) } 82 scope :personal, ->(user) { where(namespace_id: user.namespace_id) }
83 scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) } 83 scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) }
  84 + scope :public, where(public: true)
84 85
85 class << self 86 class << self
86 def active 87 def active
app/views/layouts/_head.html.haml
@@ -6,12 +6,14 @@ @@ -6,12 +6,14 @@
6 = favicon_link_tag 'favicon.ico' 6 = favicon_link_tag 'favicon.ico'
7 = stylesheet_link_tag "application" 7 = stylesheet_link_tag "application"
8 = javascript_include_tag "application" 8 = javascript_include_tag "application"
9 - -# Atom feed  
10 - - if controller_name == 'projects' && action_name == 'index'  
11 - = auto_discovery_link_tag :atom, projects_url(:atom, private_token: current_user.private_token), title: "Dashboard feed"  
12 - - if @project && !@project.new_record?  
13 - - if current_controller?(:tree, :commits)  
14 - = auto_discovery_link_tag(:atom, project_commits_url(@project, @ref, format: :atom, private_token: current_user.private_token), title: "Recent commits to #{@project.name}:#{@ref}")  
15 - - if current_controller?(:issues)  
16 - = auto_discovery_link_tag(:atom, project_issues_url(@project, :atom, private_token: current_user.private_token), title: "#{@project.name} issues")  
17 = csrf_meta_tags 9 = csrf_meta_tags
  10 +
  11 + -# Atom feed
  12 + - if current_user
  13 + - if controller_name == 'projects' && action_name == 'index'
  14 + = auto_discovery_link_tag :atom, projects_url(:atom, private_token: current_user.private_token), title: "Dashboard feed"
  15 + - if @project && !@project.new_record?
  16 + - if current_controller?(:tree, :commits)
  17 + = auto_discovery_link_tag(:atom, project_commits_url(@project, @ref, format: :atom, private_token: current_user.private_token), title: "Recent commits to #{@project.name}:#{@ref}")
  18 + - if current_controller?(:issues)
  19 + = auto_discovery_link_tag(:atom, project_issues_url(@project, :atom, private_token: current_user.private_token), title: "#{@project.name} issues")
app/views/layouts/public.html.haml
1 !!! 5 1 !!! 5
2 %html{ lang: "en"} 2 %html{ lang: "en"}
3 - = render "layouts/head", title: "Error" 3 + = render "layouts/head", title: "Public Area"
4 %body{class: "#{app_theme} application"} 4 %body{class: "#{app_theme} application"}
5 %header.navbar.navbar-static-top.navbar-gitlab 5 %header.navbar.navbar-static-top.navbar-gitlab
6 .navbar-inner 6 .navbar-inner
7 .container 7 .container
8 %div.app_logo 8 %div.app_logo
9 %span.separator 9 %span.separator
10 - = link_to public_root_path, class: "home" do 10 + = link_to root_path, class: "home" do
11 %h1 GITLAB 11 %h1 GITLAB
12 %span.separator 12 %span.separator
13 - %h1.project_name Public 13 + %h1.project_name Public Area
14 .container 14 .container
15 .content 15 .content
16 .prepend-top-20 16 .prepend-top-20
app/views/public/projects/index.html.haml
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 %small Read-Only Access 3 %small Read-Only Access
4 %hr 4 %hr
5 5
6 -%ul.well-list 6 +%ul.unstyled
7 - @projects.each do |project| 7 - @projects.each do |project|
8 %li.clearfix 8 %li.clearfix
9 %h5 9 %h5