public function updateUser(UserInterface $user, $andFlush = true)
{
// Extract email part before the `@` character to use it as username is username not set
if (null === $user->getUsername()) {
$user->setUsername(substr($user->getEmail(), 0, strpos($user->getEmail(), '@')));
}
// Call parent after as does not override parent and parent do the flush
parent::updateUser($user, $andFlush);
}