Loading comments/app.js +3 −2 Original line number Diff line number Diff line Loading @@ -64,11 +64,12 @@ app.get('/auth/session', function(req, res) { if (user) { res.json({ userName: user.username, mod: user.moderator mod: user.moderator, sessionID: req.sessionID }); } else { res.json(false); res.json({sessionID: req.sessionID}); } }); }); Loading template/app/controller/Auth.js +13 −6 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ Ext.define('Docs.controller.Auth', { init: function() { this.sid = Ext.util.Cookies.get('sid'); this.currentUser = {}; this.addEvents( /** Loading Loading @@ -79,13 +80,20 @@ Ext.define('Docs.controller.Auth', { cors: true, callback: function(options, success, response) { if (response && response.responseText) { this.currentUser = JSON.parse(response.responseText); this.fireEvent('available'); if (this.currentUser) { var data = Ext.JSON.decode(response.responseText); if (data && data.sessionID) { this.setSid(data.sessionID); } if (data && data.userName) { this.currentUser = data; this.setLoggedIn(); } else { this.setLoggedOut(); } this.fireEvent('available'); } }, scope: this Loading @@ -109,7 +117,7 @@ Ext.define('Docs.controller.Auth', { password: password }, callback: function(options, success, response) { var data = JSON.parse(response.responseText); var data = Ext.JSON.decode(response.responseText); if (data.success) { this.currentUser = data; this.setSid(data.sessionID, { remember: remember }); Loading Loading @@ -155,7 +163,6 @@ Ext.define('Docs.controller.Auth', { */ setLoggedOut: function(user) { this.currentUser = {}; this.setSid(null); this.getAuth().showLoggedOut(); this.fireEvent('loggedOut'); }, Loading @@ -165,7 +172,7 @@ Ext.define('Docs.controller.Auth', { * @return {Boolean} true if the user is logged in */ isLoggedIn: function() { return Boolean(this.sid); return !!this.currentUser.userName; }, /** Loading Loading
comments/app.js +3 −2 Original line number Diff line number Diff line Loading @@ -64,11 +64,12 @@ app.get('/auth/session', function(req, res) { if (user) { res.json({ userName: user.username, mod: user.moderator mod: user.moderator, sessionID: req.sessionID }); } else { res.json(false); res.json({sessionID: req.sessionID}); } }); }); Loading
template/app/controller/Auth.js +13 −6 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ Ext.define('Docs.controller.Auth', { init: function() { this.sid = Ext.util.Cookies.get('sid'); this.currentUser = {}; this.addEvents( /** Loading Loading @@ -79,13 +80,20 @@ Ext.define('Docs.controller.Auth', { cors: true, callback: function(options, success, response) { if (response && response.responseText) { this.currentUser = JSON.parse(response.responseText); this.fireEvent('available'); if (this.currentUser) { var data = Ext.JSON.decode(response.responseText); if (data && data.sessionID) { this.setSid(data.sessionID); } if (data && data.userName) { this.currentUser = data; this.setLoggedIn(); } else { this.setLoggedOut(); } this.fireEvent('available'); } }, scope: this Loading @@ -109,7 +117,7 @@ Ext.define('Docs.controller.Auth', { password: password }, callback: function(options, success, response) { var data = JSON.parse(response.responseText); var data = Ext.JSON.decode(response.responseText); if (data.success) { this.currentUser = data; this.setSid(data.sessionID, { remember: remember }); Loading Loading @@ -155,7 +163,6 @@ Ext.define('Docs.controller.Auth', { */ setLoggedOut: function(user) { this.currentUser = {}; this.setSid(null); this.getAuth().showLoggedOut(); this.fireEvent('loggedOut'); }, Loading @@ -165,7 +172,7 @@ Ext.define('Docs.controller.Auth', { * @return {Boolean} true if the user is logged in */ isLoggedIn: function() { return Boolean(this.sid); return !!this.currentUser.userName; }, /** Loading