Open alanmels opened 2 years ago
... effectively preventing the flood control check in case if the password field is not entered
That's the point, that's a bit unclear to me. If the password is not entered, I would expect that the "field required" message is there, of course. But flood control should strike even if the form submission was incomplete, anyway? :thinking:
The odd thing: if the username is correct and the password field is empty, I also get "Sorry, unrecognized username", which for sure isn't as intended.
Maybe the first step here is to settle on expected behavior in following scenario:
Username is correct, NO password given, flood limit already reached.
This message combination in above scenario is for sure a bug:
Password field is required.
Sorry, unrecognized username.
I also believe that if password field is empty, then that should be enough to prevent further validation. However, if the current state is preserved (run through all three validation functions regardless if the first one fails), then the misleading notice should be prevented and the flood control system let to properly run it's validation.
I don't think flood protection should be involved at all unless there's a password entered... Flood protection is to prevent brute-force attacks, right? Well that's not an issue if the password's blank.
Description of the bug
The correct notice is not output to user if the password filed is empty.
Steps To Reproduce
To reproduce the behavior:
admin/config/people/login
and set either Limit login attempts by IP address or Limit login attempts by user to some low limit (eg: 1) for purpose of this test.Note, that it is the correct message.
because the account actually exists, it's just blocked.
Additional information
The problem is caused by line https://github.com/backdrop/backdrop/blob/0394202d00a9b6c8d3b5e3c1625c24e0ed0f5f75/core/modules/user/user.module#L1813 that looks like:
effectively preventing the flood control check in case if the password field is not entered and thus causing the incorrect message.
IMO, there is no need to check password in this function, because of two reasons:
user_login_name_validate()
,user_login_authenticate_validate()
,user_login_final_validate()
and all of them try to validate the password field, which is already an overkill, so I'd personally would leave the password field validation in only theuser_login_name_validate()
function which is executed first.