0

I have Google Recaptcha, but some users try to recovery password too often. I didn't find any solution for this problem. I want to make 5 attempts limit for this.

3

2 Answers 2

1

You can use the Flood Control module for it.

Flood Control provides an administration interface for hidden flood control variables, like the login attempt limiters and any future hidden variables.

1
  • 1
    This module has no affect on password reset form, just on login page Nov 2, 2020 at 15:28
1

Yes, Drupal 7 does not have such option at the moment but there is a patch and also you can create your own module to fix this.

  1. Patch https://www.drupal.org/project/drupal/issues/3074666 1.1) After applying of the patch add to the end of the file /sites/default/settings.php line that defines number of attempts:
$conf['user_pass_reset_user_limit'] = 3;
  1. Create your own module 2.1) Prepare files for your module xandeadx.ru/blog/drupal/256 2.2) Modify password reset form, code can be taken from here: https://www.drupal.org/project/drupal/issues/1681832
// xyz - your module name
function xyz_user_pass_form_validate($form, $form_state){
  // 3 - stands for number of password reset limit made during 86400 seconds
  if(!flood_is_allowed('request new password', 3, 86400, $form_state['values']['name'])){
    form_set_error('name', 'Reset password limit exceeded.  Please contact technical support for further assistance.');
  flood_register_event('request new password', 86400, $form_state['values']['name']);
  } else {
    flood_register_event('request new password', 86400, $form_state['values']['name']);
  }
}

hook_form_user_pass_alter($form){
  array_unshift($form['#validate'], 'xyz_user_pass_form_validate');
}
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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