Sleep a server action for a given delay

I’m trying to protect an application from bots attempting to break the login. One of the approaches is to introduce an increasingly large delay between responses of the server action that processes the login attempt.

I do not want to embed the wait in the client side. This must all be done on the server side.

When trying to insert a delay in the server action, however, I found that I don’t know how to do it. Is there a simple way?

The workaround I thought of is to insert a record in a table (*) with a Timestart and a Delay in seconds, and then do a repeat loop until {{now}} > Timestart + Delay but that may be too expensive in server’s CPU cycles. Moreover, I thought that most systems usually have commands to “sleep” for a given Delay but I did not find any in the server action grab bag.

Any pointers on how to do this would be very helpful!

Thanks in advance,


(*) This will be slightly more complex, because the attempt may come from a defined username or from an undefined one, but I think you get the gist.

Community Page
Last updated: