summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-01-16 16:01:15 -0800
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-01-16 16:01:15 -0800
commit41d7be3ce1ae9a4bff93b62322f35989b6ad4cf6 (patch)
tree804b510b0d4a05601395e8697402c6a3dfb4cddf /app
parentada6c6080b2fa0d63003f8b29b5c32195254906d (diff)
downloadgitlab-ce-41d7be3ce1ae9a4bff93b62322f35989b6ad4cf6.tar.gz
Allow to specify home page for non logged-in users
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin/application_settings_controller.rb1
-rw-r--r--app/controllers/application_controller.rb11
-rw-r--r--app/helpers/application_helper.rb5
-rw-r--r--app/models/application_setting.rb3
-rw-r--r--app/views/admin/application_settings/_form.html.haml4
-rw-r--r--app/views/layouts/devise.html.haml3
6 files changed, 20 insertions, 7 deletions
diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb
index 5116f1f177a..a937f484877 100644
--- a/app/controllers/admin/application_settings_controller.rb
+++ b/app/controllers/admin/application_settings_controller.rb
@@ -26,6 +26,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
:signin_enabled,
:gravatar_enabled,
:sign_in_text,
+ :home_page_url
)
end
end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index b83de68c5d2..4780a7a2a9a 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -48,6 +48,17 @@ class ApplicationController < ActionController::Base
end
end
+ def authenticate_user!
+ # If user is not signe-in and tries to access root_path - redirect him to landing page
+ if current_application_settings.home_page_url.present?
+ if current_user.nil? && controller_name == 'dashboard' && action_name == 'show'
+ redirect_to current_application_settings.home_page_url and return
+ end
+ end
+
+ super
+ end
+
def log_exception(exception)
application_trace = ActionDispatch::ExceptionWrapper.new(env, exception).application_trace
application_trace.map!{ |t| " #{t}\n" }
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 67c02f5dfa4..f65e04af205 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -292,9 +292,4 @@ module ApplicationHelper
profile_key_path(key)
end
end
-
- def redirect_from_root?
- request.env['rack.session']['user_return_to'] ==
- '/'
- end
end
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb
index 47fa6f1071c..d9c73559098 100644
--- a/app/models/application_setting.rb
+++ b/app/models/application_setting.rb
@@ -1,4 +1,7 @@
class ApplicationSetting < ActiveRecord::Base
+ validates :home_page_url, allow_blank: true,
+ format: { with: URI::regexp(%w(http https)), message: "should be a valid url" }
+
def self.current
ApplicationSetting.last
end
diff --git a/app/views/admin/application_settings/_form.html.haml b/app/views/admin/application_settings/_form.html.haml
index 5ca9585e9a9..481e7882300 100644
--- a/app/views/admin/application_settings/_form.html.haml
+++ b/app/views/admin/application_settings/_form.html.haml
@@ -26,6 +26,10 @@
.col-sm-10
= f.number_field :default_projects_limit, class: 'form-control'
.form-group
+ = f.label :home_page_url, class: 'control-label'
+ .col-sm-10
+ = f.text_field :home_page_url, class: 'form-control', placeholder: 'http://company.example.com'
+ .form-group
= f.label :sign_in_text, class: 'control-label'
.col-sm-10
= f.text_area :sign_in_text, class: 'form-control'
diff --git a/app/views/layouts/devise.html.haml b/app/views/layouts/devise.html.haml
index 857ebd9b8d9..6f805f1c9d1 100644
--- a/app/views/layouts/devise.html.haml
+++ b/app/views/layouts/devise.html.haml
@@ -6,8 +6,7 @@
= render "layouts/public_head_panel", title: ''
.container.navless-container
.content
- - unless redirect_from_root?
- = render "layouts/flash"
+ = render "layouts/flash"
.row.prepend-top-20
.col-sm-5.pull-right
= yield