diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb index 3a510b2f67c..68cbba1c9bf 100644 --- a/app/controllers/static_controller.rb +++ b/app/controllers/static_controller.rb @@ -4,7 +4,6 @@ class StaticController < ApplicationController skip_before_filter :verify_authenticity_token, only: [:enter] def show - return redirect_to('/') if current_user && params[:id] == 'login' map = { @@ -36,6 +35,15 @@ class StaticController < ApplicationController return end + file = "static/#{@page}.#{I18n.locale}" + file = "static/#{@page}.en" if lookup_context.find_all("#{file}.html").empty? + file = "static/#{@page}" if lookup_context.find_all("#{file}.html").empty? + + if lookup_context.find_all("#{file}.html").any? + render file, layout: !request.xhr?, formats: [:html] + return + end + raise Discourse::NotFound end diff --git a/spec/controllers/static_controller_spec.rb b/spec/controllers/static_controller_spec.rb index 6279c223977..4b1a6380500 100644 --- a/spec/controllers/static_controller_spec.rb +++ b/spec/controllers/static_controller_spec.rb @@ -59,8 +59,13 @@ describe StaticController do xhr :get, :show, id: 'login' response.should redirect_to '/' end - end + it "should display the login template when login is required" do + SiteSetting.stubs(:login_required).returns(true) + xhr :get, :show, id: 'login' + response.should be_success + end + end describe '#enter' do context 'without a redirect path' do