Developer forum

Forum » Development » Feature request: new notification 'Dynamicweb.Forms.Notifications.Frontend.OnBeforeSubmitSave'

Feature request: new notification 'Dynamicweb.Forms.Notifications.Frontend.OnBeforeSubmitSave'

Roald Haahr
Reply

I am looking into how to implement Google Recaptcha validation on forms, since Dynamicwebs antispam functionality does not detect spam submits from forms properly. While I can set seconds before post and max number of submits in the antispam settings, it still allows spam commits to go through with the default settings. I cannot safely set these restrictions, as I might happen to deny real submits.

So I am looking for a notification subscriber that can cancel a submit, if the submitted token from Google Recaptha does not validate. I see that there is a notification 'Dynamicweb.Forms.Notifications.Frontend.OnAfterSubmitSave' which has been suggested as a solution to my problem in this thread from 2017/2018. However, if I use this subscriber, I assume that the notification emails for the form submit will still be sent and so, I would have to subscribe to another subscriber to cancel the emails. It seems like a workaround, so I would like to be able to cancel a submit before it is saved.

Can you introduce a new notification 'Dynamicweb.Forms.Notifications.Frontend.OnBeforeSubmitSave' that is fired before a form submit is saved with the option to cancel the submit on the OnBeforeSubmitSaveArgs implementation?

Kind regards,
Roald


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Roald

I think you can use Notifications.Frontend.OnBeforeContent

Then you can test for a submit something like this:

if (!string.IsNullOrEmpty(args.ContentModule.RequestContext("cmd")))
{
    if (args.ContentModule.RequestContext("cmd").Equals("save", StringComparison.OrdinalIgnoreCase))
    {
        //secret re-capcha ninja tricks.
        args.Output = "You are not human";
        args.StopExecution = true;
    }
}

BR Nicolai

 
Roald Haahr
Reply

Hi Nicolai,

Thank you for the quick reply. :)

It looks like that could work for me - I will give it a try. Thank you!

Kind regards
Roald

 

You must be logged in to post in the forum