1

I would like to use Drupal's flood control capability in another module. I have a resource I'm protecting with a password.

Can I simply call flood_register_event() and otherwise use the variables as used in the code for user_login_final_validate()?

Am I on the right track at all, or how do I use flood control?

| improve this question | | | | |
6

You need to do 3 things when you validate your password entry form:

  1. Use flood_is_allowed() to check that the user hasn't already breached their flood limit and set a form error with form_set_error() if they have.
  2. Use flood_register_event() to log failed attempts on incorrect password errors.
  3. Use flood_clear_event() when the user enters the correct password.

You can also decide whether to do it based on uid, ipaddress, both of those, or something else entirely.

You can see the example of the user module in user_login_authenticate_validate() and user_login_final_validate(). That example may or may not be more complex than you need in your specific case.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.