Issue 13943: Notify users on login that they are blocked

This commit is contained in:
Michael 2024-12-28 00:35:44 +00:00
parent c7c029a044
commit 7342c6e468
3 changed files with 75 additions and 61 deletions

View file

@ -238,7 +238,7 @@ class Authentication
$record = $this->dba->selectFirst(
'user',
[],
['uid' => User::getIdFromPasswordAuthentication($username, $password)]
['uid' => User::getIdFromPasswordAuthentication($username, $password, false, true)]
);
} catch (Exception $e) {
$this->logger->warning('authenticate: failed login attempt', ['action' => 'login', 'username' => $username, 'ip' => $this->remoteAddress]);
@ -246,6 +246,12 @@ class Authentication
$this->baseUrl->redirect();
}
if ($record['blocked']) {
$this->logger->warning('authenticate: user is blocked', ['action' => 'login', 'username' => $username, 'ip' => $this->remoteAddress]);
DI::sysmsg()->addNotice($this->l10n->t('Login failed because your account is blocked.'));
$this->baseUrl->redirect();
}
if (!$remember) {
$trusted = $this->cookie->get('2fa_cookie_hash') ?? null;
$this->cookie->clear();