Resolving issue with saving to "paired with" user profile
This commit is contained in:
		
							
								
								
									
										6
									
								
								app.js
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								app.js
									
									
									
									
									
								
							@@ -288,6 +288,8 @@ app.post('/completed-bonfire/', function (req, res) {
 | 
			
		||||
    var isCompletedDate =  Math.round(+new Date() / 1000);
 | 
			
		||||
    var bonfireHash = req.body.bonfireInfo.bonfireHash;
 | 
			
		||||
    var isSolution = req.body.bonfireInfo.solution;
 | 
			
		||||
    // TODO
 | 
			
		||||
    debug(isCompletedWith, 'Is completed with');
 | 
			
		||||
 | 
			
		||||
    if (isCompletedWith) {
 | 
			
		||||
        var paired = User.find({"profile.username": isCompletedWith}).limit(1);
 | 
			
		||||
@@ -300,13 +302,15 @@ app.post('/completed-bonfire/', function (req, res) {
 | 
			
		||||
                if (index > -1) {
 | 
			
		||||
                    req.user.uncompletedBonfires.splice(index,1)
 | 
			
		||||
                }
 | 
			
		||||
                pairedWith = pairedWith.pop();
 | 
			
		||||
 | 
			
		||||
                //debug('This is paired with', Object.keys(pairedWith));
 | 
			
		||||
                debug('This is paired with\'s uncompleted bonfires array', pairedWith.uncompletedBonfires);
 | 
			
		||||
                index = pairedWith.uncompletedBonfires.indexOf(bonfireHash);
 | 
			
		||||
                if (index > -1) {
 | 
			
		||||
                    pairedWith.uncompletedBonfires.splice(index,1)
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                pairedWith = pairedWith.pop();
 | 
			
		||||
                pairedWith.completedBonfires.push({
 | 
			
		||||
                    _id: bonfireHash,
 | 
			
		||||
                    completedWith: req.user._id,
 | 
			
		||||
 
 | 
			
		||||
@@ -33,9 +33,12 @@ exports.index = function(req, res) {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.returnNextBonfire = function(req, res, next) {
 | 
			
		||||
 | 
			
		||||
    // TODO
 | 
			
		||||
    //var tempUser = false;
 | 
			
		||||
    if (!req.user) {
 | 
			
		||||
        req.user = new User();
 | 
			
		||||
        res.redirect('bonfires/meet-bonfire');
 | 
			
		||||
        //tempUser = true;
 | 
			
		||||
        //req.user = new User();
 | 
			
		||||
    }
 | 
			
		||||
    var currentTime = parseInt(+new Date() / 1000)
 | 
			
		||||
    if (currentTime - req.user.lastContentSync > 86400) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user