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?