Fixing Grunt Watch

This commit is contained in:
Amos Haviv
2014-05-26 01:56:08 +03:00
parent 987634ee2a
commit d9231ccc3f
2 changed files with 17 additions and 21 deletions

View File

@@ -320,28 +320,24 @@ exports.saveOAuthUserProfile = function(req, providerUserProfile, done) {
});
} else {
// User is already logged in, join the provider data to the existing user
User.findById(req.user.id, '-salt -password', function(err, user) {
if (err) {
return done(err);
} else {
// Check if user exists, is not signed in using this provider, and doesn't have that provider data already configured
if (user && user.provider !== providerUserProfile.provider && (!user.additionalProvidersData || !user.additionalProvidersData[providerUserProfile.provider])) {
// Add the provider data to the additional provider data field
if (!user.additionalProvidersData) user.additionalProvidersData = {};
user.additionalProvidersData[providerUserProfile.provider] = providerUserProfile.providerData;
var user = req.user;
// Then tell mongoose that we've updated the additionalProvidersData field
user.markModified('additionalProvidersData');
// Check if user exists, is not signed in using this provider, and doesn't have that provider data already configured
if (user.provider !== providerUserProfile.provider && (!user.additionalProvidersData || !user.additionalProvidersData[providerUserProfile.provider])) {
// Add the provider data to the additional provider data field
if (!user.additionalProvidersData) user.additionalProvidersData = {};
user.additionalProvidersData[providerUserProfile.provider] = providerUserProfile.providerData;
// And save the user
user.save(function(err) {
return done(err, user, '/#!/settings/accounts');
});
} else {
return done(err, user);
}
}
});
// Then tell mongoose that we've updated the additionalProvidersData field
user.markModified('additionalProvidersData');
// And save the user
user.save(function(err) {
return done(err, user, '/#!/settings/accounts');
});
} else {
return done(new Error('User is already connected using this provider'), user);
}
}
};

View File

@@ -87,7 +87,7 @@ module.exports = function(grunt) {
script: 'server.js',
options: {
nodeArgs: ['--debug'],
ext: 'js, html',
ext: 'js,html',
watch: watchFiles.serverViews.concat(watchFiles.serverJS)
}
}