0

I have a signup page, and here are my codes

In a router called signup.js

//somecodes
let stopspam
.get('/', async (ctx) => {
    stopspam = Math.random() //here is a randmon number
    await ctx.render('signup', {
       pagestopspam:stopspam
    });
})

.post('/reg', async (ctx) => {
   let thespamcode = JSON.parse(JSON.stringify(ctx.request.body)).spamcodevaluefrompage //here is from the page
   if(thespamcode === stopspam) {
     //can signup, if signup finished, the stopspam value will be set to null
     stopspam = ""
   }
})

The action /reg is called in ajax way, like following

$.ajax({
method: "POST",
url: "/signup/reg",
data: { password: password, spamcodevaluefrompage:spamcode, email:email}
})
.done(function( msg ) {

});

and what i meet is this seems can't stop the spam register effectively, any ideas?

yupang
  • 155
  • 1
  • 2
  • 16
  • 1) this won't work for multiple users requesting at the same time 2) just sending a number to the client which then will be sent back is not doing anything against Spam. Have a look at captchas. – Jonas Wilms Jul 14 '18 at 18:00
  • @JonasW. Thank you so much – yupang Jul 15 '18 at 01:26

0 Answers0