diff --git a/app/assets/javascripts/discourse/app/controllers/application.js b/app/assets/javascripts/discourse/app/controllers/application.js index 2d257776d82..45609c606f6 100644 --- a/app/assets/javascripts/discourse/app/controllers/application.js +++ b/app/assets/javascripts/discourse/app/controllers/application.js @@ -17,7 +17,9 @@ export default Controller.extend({ init() { this._super(...arguments); - this.showSidebar = !this.keyValueStore.getItem(HIDE_SIDEBAR_KEY); + this.showSidebar = + (this.currentUser || !this.siteSettings.login_required) && + !this.keyValueStore.getItem(HIDE_SIDEBAR_KEY); }, @discourseComputed diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-anonymous-user-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-anonymous-user-test.js index 0bdab3fc292..f88ec26083f 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-anonymous-user-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-anonymous-user-test.js @@ -20,7 +20,24 @@ acceptance("Sidebar - Anonymous User", function (needs) { assert.ok( exists(".sidebar-container"), - "sidebar exists for anonymouse user" + "sidebar exists for anonymous user" + ); + }); +}); + +acceptance("Sidebar - Anonymous User - Login Required", function (needs) { + needs.settings({ + enable_experimental_sidebar_hamburger: true, + enable_sidebar: true, + login_required: true, + }); + + test("sidebar is hidden", async function (assert) { + await visit("/"); + + assert.ok( + !exists(".sidebar-container"), + "sidebar is hidden for anonymous user" ); }); });