From 3d6e2713d167d9d47e1b377e935e04ebe62a800b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Sat, 26 Jul 2014 23:16:08 +0200 Subject: [PATCH] BUGFIX: login was broken when login was required --- app/controllers/static_controller.rb | 10 +++++++++- spec/controllers/static_controller_spec.rb | 7 ++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb index 3a510b2f6..68cbba1c9 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 6279c2239..4b1a63805 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