res.redirect is undefined in saveOAuthUserProfile
Opened this issue · 3 comments
krismp commented
I face this problem and not yet solved. I think something is left from this code. anybody experienced the same problem ?
exports.saveOAuthUserProfile = function(req, profile, done){
User.findOne({
provider: profile.provider,
providerId: profile.providerId,
},
function(err, user) {
if (err) {
return done(err);
}
else
{
if (!user) {
// console.log(profile.email.value);
var possibleUsername = profile.username || ((profile.email) ? profile.email.value.split('@')[0] : '');
User.findUniqueUsername(possibleUsername, null, function(availableUsername){
profile.username = availableUsername;
user = new User(profile);
user.save(function(err){
if (err) {
var message = getErrorMessage(err);
// var message = _this.getErrorMessage(err);
req.flash('error', message);
return res.redirect('/register');
}
return done(err, user);
});
});
}
else
{
return done(err, user);
}
}
});
};
Hitman666 commented
Actually, this is the exact code and nothing is missing. Can you please explain in more detail in which case you get this error?
mauhpr commented
i experience the same problem , the res object is not passed to the callback so you get and error in that line, but unfortunaly i dont khow yet how to fix this errors.
Hitman666 commented
Hey, would you mind putting your example to Github so that I can clone it and try on your example?