Skip to content

Commit

Permalink
Hack to access user object client-side
Browse files Browse the repository at this point in the history
TODO: fix this shit man...
  • Loading branch information
schallert committed Dec 4, 2012
1 parent 7a4b0eb commit 0f8f700
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 5 additions & 1 deletion public/javascripts/htchr.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

// TODO: make this less FUCKING SHAMELESSLY HACKY
var globalUser = {};
$.getJSON('/users/current.json', function (userRes) {
globalUser = userRes;
});

//Geolocation shim, a la 15-237 lecture.
var nop = function(){};
Expand Down
14 changes: 11 additions & 3 deletions routes/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@ var User = require('../db/models.js').User;
module.exports = {
profile_JSON: function (req, res) {
var id = req.params.id;
User.findById(id, function (err, user) {
res.end(JSON.stringify(user));
});

if (id === 'current') {
res.end(JSON.stringify(req.user));
}

else {
User.findById(id, function (err, user) {
if (err) { res.end('error'); }
else { res.end(JSON.stringify(user)) };
});
}
}
}

0 comments on commit 0f8f700

Please sign in to comment.