From 1eb81055cb661d0392c4a229cf4eb2c1a82f78fa Mon Sep 17 00:00:00 2001 From: Vikas Chauhan Date: Mon, 1 Jan 2024 21:16:11 +0530 Subject: [PATCH 1/2] Added Honeypot Field --- client/agora/public/css/agora-theme.css | 10 ++++++++++ client/agora/views/user-signup.ejs | 1 + server/controller/userController.js | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/client/agora/public/css/agora-theme.css b/client/agora/public/css/agora-theme.css index 04117020..fe059780 100644 --- a/client/agora/public/css/agora-theme.css +++ b/client/agora/public/css/agora-theme.css @@ -2215,4 +2215,14 @@ input:checked+.slider:after { /* Form stuff */ .form-control-lg { margin-bottom: 10px; +} +/* CSS Class for Honeypot Field */ +.address-field { + opacity: 0; + position: absolute; + top: 0; + left: 0; + height: 0; + width: 0; + z-index: -1; } \ No newline at end of file diff --git a/client/agora/views/user-signup.ejs b/client/agora/views/user-signup.ejs index f16b762d..0bf15608 100644 --- a/client/agora/views/user-signup.ejs +++ b/client/agora/views/user-signup.ejs @@ -99,6 +99,7 @@
To get started we need your email and name
We'll never share your information with anyone else. + Username must be unique diff --git a/server/controller/userController.js b/server/controller/userController.js index aa48d07d..ddfbda11 100644 --- a/server/controller/userController.js +++ b/server/controller/userController.js @@ -69,6 +69,11 @@ exports.createUserForm = async function( req, res ) { res.setHeader( 'Content-Type', 'text/html' ); if( req && req.body ) { + // If there is anything in honeypotField, just return error + let honeypotField = req.body.userAddress; + if( honeypotField ){ + res.render( 'user-signup', {error_message: "Error signing up!"} ); + } if( req.body.userEmail ) { // create model From 242d7d2a6a433d25190b99bbdfedb38e03a5241e Mon Sep 17 00:00:00 2001 From: Brian Gormanly Date: Mon, 1 Jan 2024 22:21:11 -0500 Subject: [PATCH 2/2] Update userController.js added quick-fix for double response send when honeypot is triggered. --- server/controller/userController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/controller/userController.js b/server/controller/userController.js index ddfbda11..eac22cc6 100644 --- a/server/controller/userController.js +++ b/server/controller/userController.js @@ -74,7 +74,7 @@ exports.createUserForm = async function( req, res ) { if( honeypotField ){ res.render( 'user-signup', {error_message: "Error signing up!"} ); } - if( req.body.userEmail ) { + else if( req.body.userEmail ) { // create model let email = req.body.userEmail;