Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
Fixing Grunt Watch
Browse files Browse the repository at this point in the history
  • Loading branch information
amoshaviv committed May 25, 2014
1 parent 987634e commit d9231cc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
40 changes: 18 additions & 22 deletions app/controllers/users.server.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

// 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(err, user);
}
}
});
var user = req.user;

// 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;

// 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);
}
}
};

Expand Down
2 changes: 1 addition & 1 deletion gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down

0 comments on commit d9231cc

Please sign in to comment.