refactor make account private action to use updateAttribute instead of save
This commit is contained in:
@ -418,33 +418,13 @@ module.exports = function(app) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function toggleLockdownMode(req, res, next) {
|
function toggleLockdownMode(req, res, next) {
|
||||||
if (req.user.isLocked === true) {
|
return User.findById(req.accessToken.userId, function(err, user) {
|
||||||
req.user.isLocked = false;
|
|
||||||
return req.user.save(function(err) {
|
|
||||||
if (err) { return next(err); }
|
if (err) { return next(err); }
|
||||||
|
user.updateAttribute('isLocked', typeof user.isLocked !== "undefined" ? !user.isLocked : true, function(err) {
|
||||||
req.flash('success', {
|
if (err) { return next(err); }
|
||||||
msg: dedent`
|
req.flash('info', { msg: 'Privacy preferences updated successfully.' });
|
||||||
Other people can now view all your challenge solutions.
|
|
||||||
You can change this back at any time in the "Manage My Account"
|
|
||||||
section at the bottom of this page.
|
|
||||||
`
|
|
||||||
});
|
|
||||||
res.redirect('/settings');
|
res.redirect('/settings');
|
||||||
});
|
});
|
||||||
}
|
|
||||||
req.user.isLocked = true;
|
|
||||||
return req.user.save(function(err) {
|
|
||||||
if (err) { return next(err); }
|
|
||||||
|
|
||||||
req.flash('success', {
|
|
||||||
msg: dedent`
|
|
||||||
All your challenge solutions are now hidden from other people.
|
|
||||||
You can change this back at any time in the "Manage My Account"
|
|
||||||
section at the bottom of this page.
|
|
||||||
`
|
|
||||||
});
|
|
||||||
res.redirect('/settings');
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user