mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Test userObj on server route, attempt to fixing crashing server
This commit is contained in:
@@ -35,11 +35,20 @@ module.exports = function(expressApp, root, derby) {
|
||||
model = req.getModel();
|
||||
model.session.userId = uid;
|
||||
return model.fetch("users." + uid, function(err, user) {
|
||||
var delta, result;
|
||||
if (err || _.isEmpty(user.get())) {
|
||||
err || (err = 'No user with that ID');
|
||||
var delta, result, userObj;
|
||||
if (err) {
|
||||
return res.send(500, err);
|
||||
}
|
||||
userObj = user.get();
|
||||
if (!(userObj && userObj.stats && userObj.stats.money && !_.isEmpty(userObj.tasks))) {
|
||||
console.log({
|
||||
taskId: taskId,
|
||||
direction: direction,
|
||||
user: userObj,
|
||||
error: 'non-user attempted to score'
|
||||
});
|
||||
return res.send(500, "User " + uid + " not found");
|
||||
}
|
||||
model.ref('_user', user);
|
||||
if (!model.get("_user.tasks." + taskId)) {
|
||||
model.refList("_habitList", "_user.tasks", "_user.habitIds");
|
||||
|
||||
Reference in New Issue
Block a user