mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-28 04:30:08 +02:00
Show a more helpfull error message on login when a user is disabled.
Before a generic invalid credentials message was shown, now a hint about the disabled status is shown.
This commit is contained in:
parent
59ec215b12
commit
c6ad14d641
2 changed files with 19 additions and 2 deletions
|
@ -44,14 +44,19 @@ namespace App\Security;
|
|||
|
||||
use App\Entity\UserSystem\User;
|
||||
use Symfony\Component\Security\Core\Exception\AccountStatusException;
|
||||
use Symfony\Component\Security\Core\Exception\CustomUserMessageAccountStatusException;
|
||||
use Symfony\Component\Security\Core\Exception\DisabledException;
|
||||
use Symfony\Component\Security\Core\User\UserCheckerInterface;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
final class UserChecker implements UserCheckerInterface
|
||||
{
|
||||
public function __construct()
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
public function __construct(TranslatorInterface $translator)
|
||||
{
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,7 +82,8 @@ final class UserChecker implements UserCheckerInterface
|
|||
|
||||
//Check if user is disabled. Then dont allow login
|
||||
if ($user->isDisabled()) {
|
||||
throw new DisabledException();
|
||||
//throw new DisabledException();
|
||||
throw new CustomUserMessageAccountStatusException($this->translator->trans('user.login_error.user_disabled'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue