diff --git a/index.js b/index.js index 9431656..f44fd71 100644 --- a/index.js +++ b/index.js @@ -147,7 +147,17 @@ DB.getDB.then((DB) => { if (!username || !password || !email) return res.json({ status: "Incomplete information!" }); // Check if the new user has an invitation. // TODO: Alert admin of signup attempts via email. - if (!await DB.getInvitation(email)) return res.json({ status: "Not invitation found!" }); + if (!await DB.getInvitation(email)){ + client_logger.capture({ + distinctId: 'app_level', + event: 'server@'+req.method+'@'+req.originalUrl+'@NotInvited', + properties: { + username: username, + email: email, + } + }); + return res.json({ status: "Not invitation found!" }); + } let isUserAlreadyRegistered = await DB.getUser(email); if(isUserAlreadyRegistered && isUserAlreadyRegistered._id) return res.json({status: "This user is already registered"}); // Hash password to be stored on the DB. @@ -175,7 +185,14 @@ DB.getDB.then((DB) => { return await login(req, res); } // Error return - return res.json({ status: response }) + client_logger.capture({ + distinctId: 'app_level', + event: 'server@'+req.method+'@'+req.originalUrl+'@error', + properties: { + ustatus: newUserObject, + } + }); + return res.json({ status: newUserObject }) } app.route('/signup').get(async (req, res) => { // Allow get and post to test on browser. return await signup(req, res);