mirror of
https://github.com/discourse/discourse.git
synced 2025-03-06 03:09:43 +00:00
Redirect Ember routes to login if login required
This commit is contained in:
parent
789289a290
commit
122f9188c9
@ -168,6 +168,10 @@ Discourse = Ember.Application.createWithMixins({
|
|||||||
);
|
);
|
||||||
}.property(),
|
}.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
|
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
|
for performance reasons. Also automatically adjusts the URL to support installs
|
||||||
|
@ -28,7 +28,7 @@ Discourse.StaticController = Discourse.Controller.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
Discourse.StaticController.reopenClass({
|
Discourse.StaticController.reopenClass({
|
||||||
pages: ['faq', 'tos', 'privacy']
|
pages: ['faq', 'tos', 'privacy', 'login']
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
**/
|
**/
|
||||||
Discourse.FilteredListRoute = Discourse.Route.extend({
|
Discourse.FilteredListRoute = Discourse.Route.extend({
|
||||||
|
|
||||||
|
redirect: function() { Discourse.redirectIfLoginRequired(this); },
|
||||||
|
|
||||||
exit: function() {
|
exit: function() {
|
||||||
this._super();
|
this._super();
|
||||||
|
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
**/
|
**/
|
||||||
Discourse.ListCategoriesRoute = Discourse.Route.extend({
|
Discourse.ListCategoriesRoute = Discourse.Route.extend({
|
||||||
|
|
||||||
|
redirect: function() { Discourse.redirectIfLoginRequired(this); },
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
|
|
||||||
createCategory: function() {
|
createCategory: function() {
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
**/
|
**/
|
||||||
Discourse.TopicRoute = Discourse.Route.extend({
|
Discourse.TopicRoute = Discourse.Route.extend({
|
||||||
|
|
||||||
|
redirect: function() { Discourse.redirectIfLoginRequired(this); },
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
// Modals that can pop up within a topic
|
// 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
|
resources :static
|
||||||
post 'login' => 'static#enter'
|
post 'login' => 'static#enter'
|
||||||
|
get 'login' => 'static#show', id: 'login'
|
||||||
get 'faq' => 'static#show', id: 'faq'
|
get 'faq' => 'static#show', id: 'faq'
|
||||||
get 'tos' => 'static#show', id: 'tos'
|
get 'tos' => 'static#show', id: 'tos'
|
||||||
get 'privacy' => 'static#show', id: 'privacy'
|
get 'privacy' => 'static#show', id: 'privacy'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user