diff --git a/app/assets/javascripts/discourse/widgets/header.js.es6 b/app/assets/javascripts/discourse/widgets/header.js.es6 index 03fe6a6901..e4abd88493 100644 --- a/app/assets/javascripts/discourse/widgets/header.js.es6 +++ b/app/assets/javascripts/discourse/widgets/header.js.es6 @@ -104,6 +104,8 @@ createWidget('header-icons', { }, html(attrs) { + if (this.siteSettings.login_required && !this.currentUser) { return []; } + const hamburger = this.attach('header-dropdown', { title: 'hamburger_menu', icon: 'bars', diff --git a/test/javascripts/acceptance/login-required-test.js.es6 b/test/javascripts/acceptance/login-required-test.js.es6 index abdb2eea94..4bbec697a4 100644 --- a/test/javascripts/acceptance/login-required-test.js.es6 +++ b/test/javascripts/acceptance/login-required-test.js.es6 @@ -26,19 +26,4 @@ test("redirect", () => { andThen(() => { ok(invisible('.login-modal'), "it closes the login modal"); }); - - click('#search-button'); - andThen(() => { - ok(exists('.login-modal'), "clicking search opens the login modal"); - }); - - click('.modal-header .close'); - andThen(() => { - ok(invisible('.login-modal'), "it closes the login modal"); - }); - - click('#toggle-hamburger-menu'); - andThen(() => { - ok(exists('.login-modal'), "site map opens the login modal"); - }); }); diff --git a/test/javascripts/widgets/header-test.js.es6 b/test/javascripts/widgets/header-test.js.es6 index f3a7b8f907..71676a0338 100644 --- a/test/javascripts/widgets/header-test.js.es6 +++ b/test/javascripts/widgets/header-test.js.es6 @@ -35,3 +35,41 @@ widgetTest('sign up / login buttons', { }); } }); + +widgetTest('anon when login required', { + template: '{{mount-widget widget="header" showCreateAccount="showCreateAccount" showLogin="showLogin" args=args}}', + anonymous: true, + + setup() { + this.set('args', { canSignUp: true }); + this.on('showCreateAccount', () => this.signupShown = true); + this.on('showLogin', () => this.loginShown = true); + this.siteSettings.login_required = true; + }, + + test(assert) { + assert.ok(exists('button.login-button')); + assert.ok(exists('button.sign-up-button')); + assert.ok(!exists('#search-button')); + assert.ok(!exists('#toggle-hamburger-menu')); + } +}); + +widgetTest('logged in when login required', { + template: '{{mount-widget widget="header" showCreateAccount="showCreateAccount" showLogin="showLogin" args=args}}', + + setup() { + this.set('args', { canSignUp: true }); + this.on('showCreateAccount', () => this.signupShown = true); + this.on('showLogin', () => this.loginShown = true); + this.siteSettings.login_required = true; + }, + + test(assert) { + assert.ok(!exists('button.login-button')); + assert.ok(!exists('button.sign-up-button')); + assert.ok(exists('#search-button')); + assert.ok(exists('#toggle-hamburger-menu')); + assert.ok(exists('#current-user')); + } +});