diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/application_controller.rb | 6 | ||||
-rw-r--r-- | app/controllers/auth/registrations_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/home_controller.rb | 2 |
3 files changed, 7 insertions, 3 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 61ca71123..0c320177d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -8,7 +8,7 @@ class ApplicationController < ActionController::Base force_ssl if: "Rails.env.production? && ENV['LOCAL_HTTPS'] == 'true'" include Localized - helper_method :current_account + helper_method :current_account, :single_user_mode? rescue_from ActionController::RoutingError, with: :not_found rescue_from ActiveRecord::RecordNotFound, with: :not_found @@ -69,6 +69,10 @@ class ApplicationController < ActionController::Base end end + def single_user_mode? + @single_user_mode ||= Rails.configuration.x.single_user_mode && Account.first + end + def current_account @current_account ||= current_user.try(:account) end diff --git a/app/controllers/auth/registrations_controller.rb b/app/controllers/auth/registrations_controller.rb index 4881c074a..f8050afb5 100644 --- a/app/controllers/auth/registrations_controller.rb +++ b/app/controllers/auth/registrations_controller.rb @@ -28,7 +28,7 @@ class Auth::RegistrationsController < Devise::RegistrationsController end def check_enabled_registrations - redirect_to root_path if Rails.configuration.x.single_user_mode || !Setting.open_registrations + redirect_to root_path if single_user_mode? || !Setting.open_registrations end private diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 65ac10692..2d1cf74f0 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -13,7 +13,7 @@ class HomeController < ApplicationController private def authenticate_user! - redirect_to(Rails.configuration.x.single_user_mode ? account_path(Account.first) : about_path) unless user_signed_in? + redirect_to(single_user_mode? ? account_path(Account.first) : about_path) unless user_signed_in? end def find_or_create_access_token |