From: Benjamin Auder Date: Fri, 11 Dec 2020 14:16:57 +0000 (+0100) Subject: Update tournament DB at each user registration X-Git-Url: https://git.auder.net/doc/html/pieces/app_dev.php/common.css?a=commitdiff_plain;h=0aa79c55c471b6a816723b021b3b50c9f6b0dec6;p=vchess.git Update tournament DB at each user registration --- diff --git a/server/config/parameters.js.dist b/server/config/parameters.js.dist index 9ba76182..b7abc139 100644 --- a/server/config/parameters.js.dist +++ b/server/config/parameters.js.dist @@ -5,7 +5,7 @@ module.exports = { // To know in which environment the code run env: process.env.NODE_ENV || 'development', - + // CORS: cross-origin resource sharing options cors: { enable: true, @@ -21,6 +21,9 @@ module.exports = { expire: 30*60*1000, //30 minutes in milliseconds }, + // Path to tournament repository (to synchronize DBs) + tourneyPath: "/path/to/folder", + // Email settings mail: { host: "mail_host_address", diff --git a/server/routes/users.js b/server/routes/users.js index 51c3063e..21585c7c 100644 --- a/server/routes/users.js +++ b/server/routes/users.js @@ -5,6 +5,7 @@ const genToken = require("../utils/tokenGenerator"); const access = require("../utils/access"); const params = require("../config/parameters"); const sanitizeHtml_pkg = require('sanitize-html'); +const { exec } = require("child_process"); const allowedTags = [ 'h3', 'h4', 'h5', 'h6', 'blockquote', 'p', 'a', 'ul', 'ol', 'li', 'b', @@ -49,6 +50,8 @@ router.post('/register', access.unlogged, access.ajax, (req,res) => { email: email }; setAndSendLoginToken("Welcome to " + params.siteURL, user); + // Update tournament DB (TODO: if error, log it) + exec(params.tourneyPath + "/sync_users.py"); res.json({}); } });