Skip to content

Node.js based forum software built for the modern web

closes #2528

barisusakli8ed06eb7734d
diff --git a/public/src/app.js b/public/src/app.js
index 64ebe9b84c..7cf640da72 100644
--- a/public/src/app.js
+++ b/public/src/app.js
@@ -2,15 +2,17 @@
/*global io, templates, translator, ajaxify, utils, bootbox, RELATIVE_PATH, config*/
var socket,
- app = {
- 'username': null,
- 'uid': null,
- 'isFocused': true,
- 'isConnected': false,
- 'currentRoom': null,
- 'widgets': {},
- 'cacheBuster': null
- };
+ app = app || {};
+
+app.isFocused = true;
+app.isConnected = false;
+app.currentRoom = null;
+app.widgets = {};
+app.cacheBuster = null;
+
+// TODO: deprecate in 0.7.0, use app.user
+app.username = null;
+app.uid = null;
(function () {
var showWelcomeMessage = false;
@@ -35,8 +37,6 @@ var socket,
app.uid = data.uid;
app.isAdmin = data.isAdmin;
- app.user = data;
-
app.showLoginMessage();
app.replaceSelfLinks();
$(window).trigger('action:connected');
diff --git a/src/middleware/middleware.js b/src/middleware/middleware.js
index 25691d0e42..17e868a576 100644
--- a/src/middleware/middleware.js
+++ b/src/middleware/middleware.js
@@ -264,7 +264,7 @@ middleware.renderHeader = function(req, res, callback) {
}
}
- templateValues.config = JSON.stringify(res.locals.config);
+ templateValues.configJSON = JSON.stringify(res.locals.config);
templateValues.metaTags = defaultMetaTags.concat(res.locals.metaTags || []).map(function(tag) {
if(!tag || typeof tag.content !== 'string') {
@@ -315,7 +315,14 @@ middleware.renderHeader = function(req, res, callback) {
if (uid) {
user.getUserFields(uid, ['username', 'userslug', 'picture', 'status', 'banned'], next);
} else {
- next();
+ next(null, {
+ username: '[[global:guest]]',
+ userslug: '',
+ picture: user.createGravatarURLFromEmail(''),
+ status: 'offline',
+ banned: false,
+ uid: 0
+ });
}
}
}, function(err, results) {
@@ -328,10 +335,12 @@ middleware.renderHeader = function(req, res, callback) {
res.redirect('/');
return;
}
+ results.user.isAdmin = results.isAdmin || false;
templateValues.browserTitle = results.title;
- templateValues.isAdmin = results.isAdmin || false;
+ templateValues.isAdmin = results.user.isAdmin;
templateValues.user = results.user;
+ templateValues.userJSON = JSON.stringify(results.user);
templateValues.customCSS = results.customCSS;
templateValues.customJS = results.customJS;
templateValues.maintenanceHeader = parseInt(meta.config.maintenanceMode, 10) === 1 && !results.isAdmin;