The real error was due to the fact that I wrote callbackUrl instead of callbackURL when pushing into the strategies.
And, as I'm developing with version 1.12.2, I can't just return the results as this version does not support promises.
I'm making a call from register.js to socket.io using the following function
function validateInviteCode(code, use, callback) {
callback = callback || function() {};
var invite_code_notify = $('#invite_code_notify');
if (!code.includes(':') || code.split(':')[1].length != 8) {
showError(invite_code_notify, 'Invalid invite code');
return callback();
}
socket.emit('plugins.invite.checkInviteCode', {
code: code,
use: use
}, function(err, valid) {
if (err) {
console.log(err);
app.alertError(err.message);
return callback();
}
console.log(valid);
if (valid) {
showSuccess(invite_code_notify, successIcon);
} else {
showError(invite_code_notify, 'Invalid invite code');
}
callback();
});
}
and it's returning err as an empty object { }. This is my server-side listen for it:
checkInviteCode: function (socket, data, fn) {
checkCode(data.code, data.use, function(valid) {
console.log(data, valid);
fn(!socket.uid, valid);
});
}
In your server code, looks like your responding with a boolean value !socket.uid
when it expects an Error object or null. You can use a ternary operator ? :
to check the uid and send the appropriate response.
Also, the data parameter should always be a plain object, and not a literal value.
e.g.
fn(!socket.uid ? new Error("Invalid uid") : null, {valid: valid})
Ooops! I'm sorry haha, this headache is giving me coding troubles. Thanks!