reached a stopping point, trying to fix a production bug
This commit is contained in:
31
app.js
31
app.js
@ -168,24 +168,19 @@ app.get('/account/unlink/:provider', userController.getOauthUnlink);
|
|||||||
*/
|
*/
|
||||||
app.post('/completed_challenge', function(req, res) {
|
app.post('/completed_challenge', function(req, res) {
|
||||||
console.log(req.user);
|
console.log(req.user);
|
||||||
|
req.user.challengesHash[parseInt(req.body.cn)] = Math.round(+new Date() / 1000);
|
||||||
User.findById(req.user.id, function (err, user) {
|
req.user.challengesCompleted = function() {
|
||||||
if (err) {
|
var completed = [];
|
||||||
console.log(err);
|
for (i = 0; i < h.length; i++) {
|
||||||
res.status(500);
|
if (h[i] > 0) {
|
||||||
return res.send('something went wrong');
|
completed.push(i);
|
||||||
}
|
}
|
||||||
user.challengesHash[parseInt(req.body.cn)] = Math.round(+new Date()/1000);
|
return completed;
|
||||||
user.save(function(err, newDats) {
|
}
|
||||||
if (err) {
|
}
|
||||||
console.log(err);
|
req.user.save();
|
||||||
res.status(500);
|
console.log(req.user.challengesHash);
|
||||||
return res.send('something went wrong');
|
console.log(req.user.challengesCompleted);
|
||||||
}
|
|
||||||
console.log('Suer', user);
|
|
||||||
res.status(200).send('saved');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,7 +6,8 @@
|
|||||||
exports.index = function(req, res) {
|
exports.index = function(req, res) {
|
||||||
if (req.user) {
|
if (req.user) {
|
||||||
if (req.user.challengesCompleted.length > 0) {
|
if (req.user.challengesCompleted.length > 0) {
|
||||||
nextChallenge = Math.max.apply(Math, req.user.challengesCompleted) + 1;
|
Object.values(req.user.challengesHash);
|
||||||
|
nextChallenge = Math.max.apply(Math, req.user.challengesHash) + 1;
|
||||||
res.redirect("challenges/" + nextChallenge);
|
res.redirect("challenges/" + nextChallenge);
|
||||||
} else {
|
} else {
|
||||||
res.redirect("challenges/0");
|
res.redirect("challenges/0");
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
img(src='#{user.profile.picture}')
|
img(src='#{user.profile.picture}')
|
||||||
else
|
else
|
||||||
img(src='#{user.gravatar(60)}')
|
img(src='#{user.gravatar(60)}')
|
||||||
| #{user.profile.name || user.email || user.id} [ #{Object.keys(user.challengesHash).length} ]
|
| #{user.profile.name || user.email || user.id} [ #{user.completedChallengeCount)} ]
|
||||||
i.caret
|
i.caret
|
||||||
ul.dropdown-menu
|
ul.dropdown-menu
|
||||||
li
|
li
|
||||||
a(href='/')
|
a(href='/')
|
||||||
|
Reference in New Issue
Block a user