mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
Redirect Ember routes to login if login required
This commit is contained in:
parent
789289a290
commit
122f9188c9
7 changed files with 25 additions and 1 deletions
|
@ -168,6 +168,10 @@ Discourse = Ember.Application.createWithMixins({
|
|||
);
|
||||
}.property(),
|
||||
|
||||
redirectIfLoginRequired: function(route) {
|
||||
if(this.get('loginRequired')) { route.transitionTo('login'); }
|
||||
},
|
||||
|
||||
/**
|
||||
Our own $.ajax method. Makes sure the .then method executes in an Ember runloop
|
||||
for performance reasons. Also automatically adjusts the URL to support installs
|
||||
|
|
|
@ -28,7 +28,7 @@ Discourse.StaticController = Discourse.Controller.extend({
|
|||
});
|
||||
|
||||
Discourse.StaticController.reopenClass({
|
||||
pages: ['faq', 'tos', 'privacy']
|
||||
pages: ['faq', 'tos', 'privacy', 'login']
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
**/
|
||||
Discourse.FilteredListRoute = Discourse.Route.extend({
|
||||
|
||||
redirect: function() { Discourse.redirectIfLoginRequired(this); },
|
||||
|
||||
exit: function() {
|
||||
this._super();
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
**/
|
||||
Discourse.ListCategoriesRoute = Discourse.Route.extend({
|
||||
|
||||
redirect: function() { Discourse.redirectIfLoginRequired(this); },
|
||||
|
||||
events: {
|
||||
|
||||
createCategory: function() {
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
**/
|
||||
Discourse.TopicRoute = Discourse.Route.extend({
|
||||
|
||||
redirect: function() { Discourse.redirectIfLoginRequired(this); },
|
||||
|
||||
events: {
|
||||
// Modals that can pop up within a topic
|
||||
|
||||
|
|
13
app/views/static/login.en.html.erb
Normal file
13
app/views/static/login.en.html.erb
Normal file
|
@ -0,0 +1,13 @@
|
|||
<ul class="nav-pills">
|
||||
<li><a class='active' href="<%=login_path%>">Welcome</a></li>
|
||||
<li><a href="<%=faq_path%>">FAQ</a></li>
|
||||
<li><a href="<%=tos_path%>">Terms of Service</a></li>
|
||||
<li><a href="<%=privacy_path%>">Privacy</a></li>
|
||||
</ul>
|
||||
|
||||
<h2><a href="#welcome">Welcome to <%= SiteSetting.title %></a></h2>
|
||||
|
||||
<p>
|
||||
We are excited to have you participate in <%= SiteSetting.title %>. Please
|
||||
create an account or login to continue.
|
||||
</p>
|
|
@ -103,6 +103,7 @@ Discourse::Application.routes.draw do
|
|||
|
||||
resources :static
|
||||
post 'login' => 'static#enter'
|
||||
get 'login' => 'static#show', id: 'login'
|
||||
get 'faq' => 'static#show', id: 'faq'
|
||||
get 'tos' => 'static#show', id: 'tos'
|
||||
get 'privacy' => 'static#show', id: 'privacy'
|
||||
|
|
Loading…
Reference in a new issue