discourse/discourse — pull request #951 by chrishunt (2013-06-03 23:57:25+00:00)
Title: WIP: Add 'login required' site setting

*Don't merge yet, submitting for feedback*

I'm submitting this PR a bit early to get feedback because I suck at Ember.

My goal is to create a 'login required' site setting so that folks needs to be logged in to read topics.

At the rails level, this is easy with a [before filter](https://github.com/chrishunt/discourse/commit/d27cd0f0127a1ad39fb7e3c7a71b29dabe9f1388). This works fine if someone navigates directly to a topic. They're just redirect back to `/`

I'm having trouble with the Ember side of things though. I'd like the topic list to still be visible when logged out, but have the login modal appear when a topic link is clicked. The code in this PR works fine for this, but I have duplicated logic in [`header_controller.js#L13`](https://github.com/chrishunt/discourse/blob/ba7f8c17efb4f9da8acd44aa322ca316ba453ddf/app/assets/javascripts/discourse/controllers/header_controller.js#L13) and in [`list_topics_controller.js#L18`](https://github.com/chrishunt/discourse/blob/ba7f8c17efb4f9da8acd44aa322ca316ba453ddf/app/assets/javascripts/discourse/controllers/list_topics_controller.js#L18).

Can anyone help me get rid of this duplication? Where can I place `loginRequired()` so that both `header.js.handlebars` and `topic_list_item.js.handlebars` can see it?