Problem/Motivation
When anonymous visitors attempt to register themselves, they get an error message. The user is created successfully.
The call $config->get('user_otp_generate_time_window') returns an empty string "".
The creation via the page /admin/people/create is not affected.
Steps to reproduce
- Install the module on a fresh Drupal
- Never visit the config form of OTP
- Log out
- Visit /user/register and attempt to create a new user.
Proposed resolution
Fix the TypeError by using the same default as in the config form. This new code at line 147 fixes the problem:
$hours = $config->get('user_otp_generate_time_window') ?: 3;
$threshold = $config->get('user_otp_generate_threshold');
$seconds = 60 * 60 * $hours;
if (!Drupal::flood()->isAllowed('user_otp', $threshold, $seconds, $account->getEmail())) {
return FALSE;
}
Drupal::flood()->register('user_otp', $seconds, $account->getEmail());
User interface changes
None
Comments
Comment #3
gogowitsch commentedPlease review the merge request !2. I have added the defaults that the form uses to:
The default email body was very hard to understand. Most of our website visitors would not know what Drupal is. Let’s say registration instead of transaction. Let’s always use the same term for the 6-digit code.