diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-09-24 16:58:39 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-09-24 16:58:39 +0400 |
commit | 66998f6d46ee778e6bde749e41f1d712b184a771 (patch) | |
tree | 6b81a984cdc61ed084bdceeaf2876eaa250cf75d /app/controllers/projects/application_controller.rb | |
parent | e894e3eea505ebd675b90c3c53382fd8f273ced8 (diff) |
Allow non authenticated user access to public projects
Diffstat (limited to 'app/controllers/projects/application_controller.rb')
-rw-r--r-- | app/controllers/projects/application_controller.rb | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb index 1f2a75175cf..d525bd4a700 100644 --- a/app/controllers/projects/application_controller.rb +++ b/app/controllers/projects/application_controller.rb @@ -1,5 +1,26 @@ class Projects::ApplicationController < ApplicationController before_filter :project before_filter :repository - layout 'projects' + 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) + + return if @project && @project.public + end + + super + end + + def determine_layout + if current_user + 'projects' + else + 'public' + end + end end |