我使用FOSUserBundle和Symfony 3.4登录我的用户。当他们输入错误的密码时,将显示以下消息:

我希望为用户类型添加一个检查,并添加一个自定义错误消息,例如:“您必须是一个客户才能登录。”
为了完成这个任务,我实现了一个用户检查器,但它并不像预期的那样工作:
class CustomerUserChecker implements UserCheckerInterface
{
public function checkPreAuth(UserInterface $user)
{
// nothing to do here
return;
}
public function checkPostAuth(UserInterface $user)
{
if (!$user instanceof CustomerUser) {
throw new AuthenticationException('You must be a customer in order to login');
}
return;
}
}我得到了这个错误:

如何在文本中添加新的错误?
发布于 2018-02-28 16:06:54
另一种方法是通过将validators.en.yml从...vendor/friendsofsymfony/user-bundle/Resources/translations复制到...app/Resources/translations来覆盖它。在那里做任何想要的改变。
https://stackoverflow.com/questions/49031659
复制相似问题