Skip to content
Snippets Groups Projects
Commit 5affeaef authored by Lloyd Hilaiel's avatar Lloyd Hilaiel
Browse files

cleanup transitional code for migration from email to userid in stage table - issue #1599

parent 4dab9470
No related branches found
No related tags found
No related merge requests found
......@@ -355,32 +355,26 @@ exports.gotVerificationSecret = function(secret, cb) {
addEmailToUser(info.insertId, o.email, 'secondary', cb);
});
} else {
// we need a userid. the old schema had an 'existing' field which was an email
// address. the new schema has an 'existing_user' field which is a userid.
// this is transitional code so outstanding verification links continue working
// and can be removed in feb 2012 some time. maybe for valentines day?
if (typeof o.existing_user === 'number') doAddEmailSetPassword(o.existing_user);
else if (typeof o.existing === 'string') {
exports.emailToUID(o.existing, function(uid) {
if (err || uid === undefined) return cb('acct associated with staged email doesn\'t exist');
doAddEmailSetPassword(uid);
});
// ensure the expected existing_user field is populated, which it must always be when
// new_acct is false
if (typeof o.existing_user !== 'number') {
return cb("data inconsistency, no numeric existing user associated with staged email address");
}
function doAddEmailSetPassword(uid) {
// we're adding an email address to an existing user account. add appropriate entries into
// email table
var hash = o.passwd;
if (hash) {
exports.updatePassword(uid, hash, function(err) {
if (err) return cb('could not set user\'s password');
addEmailToUser(uid, o.email, 'secondary', cb);
});
} else {
// we're adding an email address to an existing user account. add appropriate entries into
// email table
var hash = o.passwd;
var uid = o.existing_user;
if (hash) {
exports.updatePassword(uid, hash, function(err) {
if (err) return cb('could not set user\'s password');
addEmailToUser(uid, o.email, 'secondary', cb);
}
});
} else {
addEmailToUser(uid, o.email, 'secondary', cb);
}
};
}
}
};
}
);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment