Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function then (avatarError, avatarURL) {
if (avatarURL) updates.blog.avatar = avatarURL;
User.set(uid, updates.user, function(userErrors, userChanges){
Blog.set(blogID, updates.blog, function(blogErrors, blogChanges){
var changes = userChanges.concat(blogChanges);
if (changes.indexOf('timeZone') > -1 ||
changes.indexOf('dateDisplay') > -1) {
Blog.get({id: blog.id}, function(err, blog){
Entries.each(blogID, function(entry, nextEntry){
var dateStamp = DateStamp(blog, entry.path, entry.metadata);
// This is fine!
if (dateStamp === undefined) return nextEntry();
}, function(){
User.set(old_uid, changes, function(err){
if (err) return next(err);
var multi = redis.multi();
multi.set("customer:" + customer_id, new_uid);
multi.rename("user:" + old_uid + ":info", "user:" + new_uid + ":info");
multi.exec(function(err){
if (err) return next(err);
req.session.uid = new_uid;
res.redirect('/account/change-dropbox/copy-files');
});
if (err) {
res.message({error: err.message || ERROR, url: ROUTE});
return res.redirect(req.path);
}
if (!subscription) {
res.message({error: ERROR, url: ROUTE});
return res.redirect(req.path);
}
var changes = {
subscription: subscription,
isDisabled: isDisabled
};
User.set(uid, changes, function(errors){
if (errors) throw errors;
forEach(user.blogs, function(blogID, nextBlog){
Blog.set(blogID, {isDisabled: isDisabled}, nextBlog);
}, function(){
var andDisabled = isDisabled ? ' and disabled your account' : '';
email.CANCELLED(uid, {andDisabled: andDisabled});
if (isDisabled) {
return req.session.destroy(function(){
res.redirect('/disabled');
var changes = {};
if (user.blogs.indexOf(oldBlogID) > -1) {
changes.blogs = user.blogs.filter(function(id) {
return id !== oldBlogID;
});
changes.blogs.push(newBlogID);
}
if (user.lastSession === oldBlogID) {
changes.lastSession = newBlogID;
}
if (!Object.keys(changes).length) return next();
User.set(uid, changes, next);
});
},
return callback();
}
var changes = {};
var blogs = user.blogs.slice();
blogs = blogs.filter(function(otherBlogID) {
return otherBlogID !== blog.id;
});
changes.blogs = blogs;
if (user.lastSession === blog.id) changes.lastSession = "";
User.set(blog.owner, changes, callback);
});
}