summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2019-05-09 16:17:53 +0300
committerLauri Ojansivu <x@xet7.org>2019-05-09 16:17:53 +0300
commite1b016cf3d4ff93e9e0fe1feb96372e3e1625233 (patch)
treeefef915f080c0b347c8e4362e99b356137c38836 /models
parentc8506697776c5f5ed0d82de0f4bd84bcc379db45 (diff)
downloadwekan-e1b016cf3d4ff93e9e0fe1feb96372e3e1625233.tar.gz
wekan-e1b016cf3d4ff93e9e0fe1feb96372e3e1625233.tar.bz2
wekan-e1b016cf3d4ff93e9e0fe1feb96372e3e1625233.zip
Prevent data loss.
Thanks to xet7 !
Diffstat (limited to 'models')
-rw-r--r--models/users.js26
1 files changed, 16 insertions, 10 deletions
diff --git a/models/users.js b/models/users.js
index 4ce0ca3f..5f949c80 100644
--- a/models/users.js
+++ b/models/users.js
@@ -690,16 +690,22 @@ if (Meteor.isServer) {
}, {unique: true});
});
- Users.before.remove((userId, doc) => {
- Boards
- .find({members: {$elemMatch: {userId: doc._id, isAdmin: true}}})
- .forEach((board) => {
- // If only one admin for the board
- if (board.members.filter((e) => e.isAdmin).length === 1) {
- Boards.remove(board._id);
- }
- });
- });
+ // OLD WAY THIS CODE DID WORK: When user is last admin of board,
+ // if admin is removed, board is removed.
+ // NOW THIS IS COMMENTED OUT, because other board users still need to be able
+ // to use that board, and not have board deleted.
+ // Someone can be later changed to be admin of board, by making change to database.
+ // TODO: Add UI for changing someone as board admin.
+ //Users.before.remove((userId, doc) => {
+ // Boards
+ // .find({members: {$elemMatch: {userId: doc._id, isAdmin: true}}})
+ // .forEach((board) => {
+ // // If only one admin for the board
+ // if (board.members.filter((e) => e.isAdmin).length === 1) {
+ // Boards.remove(board._id);
+ // }
+ // });
+ //});
// Each board document contains the de-normalized number of users that have
// starred it. If the user star or unstar a board, we need to update this