From e28519f25f88ee133fc8aaa766c9bd95eec6c1ba Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Fri, 11 Dec 2020 18:12:25 +0100
Subject: [PATCH] Update code to remove users in tournament DB as well

---
 server/models/User.js  | 5 ++++-
 server/routes/users.js | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/server/models/User.js b/server/models/User.js
index ebda4c32..d62cd767 100644
--- a/server/models/User.js
+++ b/server/models/User.js
@@ -171,10 +171,13 @@ const UserModel = {
           }
         });
         if (toRemove.length > 0) {
+          const remArg = toRemove.join(",");
           db.run(
             "DELETE FROM Users " +
-            "WHERE id IN (" + toRemove.join(",") + ")"
+            "WHERE id IN (" + remArg + ")"
           );
+          // Update tournament DB:
+          exec(params.tourneyPath + "/dbsync/delete_users.py " + remArg);
         }
       });
     });
diff --git a/server/routes/users.js b/server/routes/users.js
index 21585c7c..f1554ef7 100644
--- a/server/routes/users.js
+++ b/server/routes/users.js
@@ -51,7 +51,7 @@ router.post('/register', access.unlogged, access.ajax, (req,res) => {
         };
         setAndSendLoginToken("Welcome to " + params.siteURL, user);
         // Update tournament DB (TODO: if error, log it)
-        exec(params.tourneyPath + "/sync_users.py");
+        exec(params.tourneyPath + "/dbsync/update_users.py");
         res.json({});
       }
     });
-- 
2.44.0