Skip to content

Commit

Permalink
Merge pull request #539 from A-4-Atom/add-honeypot-field
Browse files Browse the repository at this point in the history
Added Honeypot Field
  • Loading branch information
briangormanly authored Jan 2, 2024
2 parents 61987e3 + 242d7d2 commit 19f3feb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions client/agora/public/css/agora-theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions client/agora/views/user-signup.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
<div class="form-group">
<h5>To get started we need your email and name</h5>
<small id="emailHelp" class="form-text text-muted">We'll never share your information with anyone else.</small>
<input type="text" class="address-field" name="userAddress" placeholder="Enter Your Address" tabindex="-1" autocomplete="off">
<input type="email" class="form-control form-control-lg" name="userEmail" id="userEmail" aria-describedby="emailHelp" placeholder="Enter email" required>
<small id="usernameHelp" class="form-text text-muted">Username must be unique</small>
<input type="input" class="form-control form-control-lg" name="userUsername" id="userUsername" aria-describedby="usernameHelp" placeholder="Enter Username" required>
Expand Down
7 changes: 6 additions & 1 deletion server/controller/userController.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ exports.createUserForm = async function( req, res ) {
res.setHeader( 'Content-Type', 'text/html' );

if( req && req.body ) {
if( req.body.userEmail ) {
// 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!"} );
}
else if( req.body.userEmail ) {

// create model
let email = req.body.userEmail;
Expand Down

0 comments on commit 19f3feb

Please sign in to comment.