prevent challenge tasks being deleted when challenge ID (cid) has been lost - possible fix for https://github.com/HabitRPG/habitrpg/issues/4466

This commit is contained in:
Alys
2015-06-27 14:19:40 +10:00
parent ac7c1a1436
commit 0fc14f129d

View File

@@ -539,6 +539,9 @@ UserSchema.pre('save', function(next) {
UserSchema.methods.unlink = function(options, cb) { UserSchema.methods.unlink = function(options, cb) {
var cid = options.cid, keep = options.keep, tid = options.tid; var cid = options.cid, keep = options.keep, tid = options.tid;
if (!cid) {
return cb("Could not remove challenge tasks. Please delete them manually.");
}
var self = this; var self = this;
switch (keep) { switch (keep) {
case 'keep': case 'keep':