Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// console.log('HERE!');
// return res.redirect('/folder/change-dropbox');
}
// Save the old credentials in the session temporarily
// so we can copy the files from the old acount in future
req.session.old_credentials = req.blog.credentials;
var updates = {dropbox: req.blog.dropbox};
updates.dropbox.id = new_account_id;
updates.dropbox.token = token;
updates.dropbox.cursor = '';
Blog.set(blogID, updates, function(err){
if (err) return next(err);
res.redirect('/folder/change-dropbox/copy-files');
});
});
};
.post(saveRedirects, form, function(req, res, next){
var blog = req.blog;
var blogID = blog.id;
var updates = req.body;
Blog.set(blogID, updates, function(err, changes){
if (err) return next(err);
if (changes && changes.length)
res.message({success: 'Made changes successfully!'});
// We now need to save every entry so that
// changes to permalink format take effect.
if (changes.indexOf('timeZone') > -1 ||
changes.indexOf('dateDisplay') > -1 ||
changes.indexOf('permalink') > -1) {
resaveEntries(blogID, function(){});
}
// We need to build all the blog's entries if the user
// has changed any of the plugins or their permalink
module.exports = function(req, res, next) {
var blog = req.blog;
var blogID = blog.id;
var updates = req.updates || {};
var redirect = req.body.redirect || req.path;
Blog.set(blogID, updates, function(errors, changes) {
if (errors)
for (var i in errors)
if (errors[i] instanceof Error)
return next(errors[i]);
if (errors) return next(errors);
// We now need to save every entry so that
// changes to permalink format take effect.
if (
changes.indexOf("timeZone") > -1 ||
changes.indexOf("dateDisplay") > -1 ||
changes.indexOf("permalink") > -1
) {
buildFromFolder(blog.id, function(err){
if (err) return callback(err);
blog.dropbox.cursor = latest_cursor;
Blog.set(blogID, blog, function(err){
if (err) return callback(err);
// No we make sure that the changes
// from dropbox conform to what we expect
// There was a bug where json.parse(json.string(change))
// was not equal to the change. so we do this in advance
callback(null, changes);
});
});
});
changes = changes.concat(res.changes || []);
// If Dropbox says there are more changes
// we get them before returning the callback.
// This is important because a rename could
// be split across two pages of file events.
if (more) return client.delta(newState, onFetch);
// Nothing has changed so we leave early
if (!changes.length) return callback();
// We save the state before dealing with the changes
// to avoid an infinite loop if one of these changes
// causes an exception. If sync enounters an exception
// it will verify the folder at a later date
Blog.set(blogID, {folderState: newState}, function(err){
if (err) throw err;
// No we make sure that the changes
// from dropbox conform to what we expect
// There was a bug where json.parse(json.string(change))
// was not equal to the change. so we do this in advance
changes = changes.map(model);
time('handle');
handle(blog, client, changes, function(err){
time.end('handle');
callback(err);
Blog.get({ id: blogID }, function(err, blog) {
if (err) return callback(err);
if (blog.avatar.indexOf(AVATAR_DIRECTORY) !== 0) return callback();
var avatar = config.cdn.origin + "/" + blog.id + blog.avatar;
console.log(colors.dim("Blog: " + blogID + " -", blog.avatar));
console.log(colors.dim("Blog: " + blogID) + " +", avatar);
Blog.set(blogID, { avatar: avatar }, callback);
});
}
Template.getMetadata(templateID, function(err, template) {
if (err || !template) return next(err || new Error("No template"));
Blog.set(blogID, updates, function(errors, changed) {
if (errors && errors.template) {
res.message(req.path, new Error(errors.template));
} else if (changed.indexOf("template") > -1) {
res.message(req.path, "Changed your template to " + template.name);
}
});
});
};
Template.getMetadata(templateID, function(err, template){
if (err || !template) return next(err || new Error("No template"));
Blog.set(blogID, updates, function (errors, changed) {
if (errors && errors.template) {
res.message(req.path, new Error(errors.template));
} else if (changed.indexOf('template') > -1) {
res.message(req.path, 'Changed your template to ' + template.name);
}
});
});
});
forEach(user.blogs, function(blogID, nextBlog){
Blog.set(blogID, {isDisabled: shouldDisable}, nextBlog);
}, function(){
forEach(user.blogs, function(blogID, nextBlog){
Blog.set(blogID, {isDisabled: isDisabled}, nextBlog);
}, function(){