mirror of
https://github.com/discourse/discourse.git
synced 2025-03-28 09:45:41 +08:00
BUGFIX: JS error when login_required is enabled
This commit is contained in:
parent
76a250300a
commit
26b7bf388e
@ -88,8 +88,7 @@ window.Discourse = Ember.Application.createWithMixins(Discourse.Ajax, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
loginRequired: function() {
|
loginRequired: function() {
|
||||||
return Discourse.SiteSettings.login_required &&
|
return Discourse.SiteSettings.login_required && !Discourse.User.current();
|
||||||
!Discourse.User.current();
|
|
||||||
}.property(),
|
}.property(),
|
||||||
|
|
||||||
redirectIfLoginRequired: function(route) {
|
redirectIfLoginRequired: function(route) {
|
||||||
|
@ -7,19 +7,18 @@
|
|||||||
Discourse.Route.buildRoutes(function() {
|
Discourse.Route.buildRoutes(function() {
|
||||||
var router = this;
|
var router = this;
|
||||||
|
|
||||||
|
// Generate static page routes
|
||||||
|
_.each(Discourse.StaticController.PAGES, function (page) {
|
||||||
|
router.route(page, { path: '/' + page });
|
||||||
|
});
|
||||||
|
|
||||||
// Topic routes
|
// Topic routes
|
||||||
this.resource('topic', { path: '/t/:slug/:id' }, function() {
|
this.resource('topic', { path: '/t/:slug/:id' }, function() {
|
||||||
this.route('fromParams', { path: '/' });
|
this.route('fromParams', { path: '/' });
|
||||||
this.route('fromParamsNear', { path: '/:nearPost' });
|
this.route('fromParamsNear', { path: '/:nearPost' });
|
||||||
});
|
});
|
||||||
|
|
||||||
// Generate static page routes
|
|
||||||
_.each(Discourse.StaticController.PAGES, function (page) {
|
|
||||||
router.route(page, { path: '/' + page });
|
|
||||||
});
|
|
||||||
|
|
||||||
this.resource('discovery', { path: '/' }, function() {
|
this.resource('discovery', { path: '/' }, function() {
|
||||||
|
|
||||||
router = this;
|
router = this;
|
||||||
|
|
||||||
// top
|
// top
|
||||||
@ -41,6 +40,7 @@ Discourse.Route.buildRoutes(function() {
|
|||||||
router.route(top + 'Category', { path: '/category/:parentSlug/:slug/l/top/' + period + '/more' });
|
router.route(top + 'Category', { path: '/category/:parentSlug/:slug/l/top/' + period + '/more' });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// filters
|
||||||
Discourse.Site.currentProp('filters').forEach(function(filter) {
|
Discourse.Site.currentProp('filters').forEach(function(filter) {
|
||||||
router.route(filter, { path: '/' + filter });
|
router.route(filter, { path: '/' + filter });
|
||||||
router.route(filter, { path: '/' + filter + '/more' });
|
router.route(filter, { path: '/' + filter + '/more' });
|
||||||
|
@ -58,16 +58,14 @@ class Site
|
|||||||
def self.cached_json(guardian)
|
def self.cached_json(guardian)
|
||||||
|
|
||||||
if guardian.anonymous? && SiteSetting.login_required
|
if guardian.anonymous? && SiteSetting.login_required
|
||||||
return {}.to_json
|
return {
|
||||||
|
periods: TopTopic.periods.map(&:to_s),
|
||||||
|
filters: Discourse.filters.map(&:to_s),
|
||||||
|
}.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sam: bumping this way down, SiteSerializer will serialize post actions as well,
|
|
||||||
# On my local this was not being flushed as post actions types changed, it turn this
|
|
||||||
# broke local.
|
|
||||||
site = Site.new(guardian)
|
site = Site.new(guardian)
|
||||||
#Discourse.cache.fetch(site.cache_key, family: "site", expires_in: 1.minute) do
|
|
||||||
MultiJson.dump(SiteSerializer.new(site, root: false))
|
MultiJson.dump(SiteSerializer.new(site, root: false))
|
||||||
#end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.invalidate_cache
|
def self.invalidate_cache
|
||||||
|
Loading…
x
Reference in New Issue
Block a user