logger->info('Refresh user.', ['user' => $user->getUserIdentifier()]); $freshUser = $this->entityManager->getRepository(User::class) ->findOneBy(['npub' => $user->getUserIdentifier()]); $metadata = $this->cacheService->getMetadata($user->getUserIdentifier()); $freshUser->setMetadata($metadata); return $freshUser; } /** * @inheritDoc */ public function supportsClass(string $class): bool { /** * Checks if the provider supports the given user class. * * @param string $class The class name to check. * @return bool True if the class is supported, false otherwise. */ return $class === User::class; } /** * @inheritDoc */ public function loadUserByIdentifier(string $identifier): UserInterface { $this->logger->info('Load user by identifier.', ['identifier' => $identifier]); // Get or create user $user = $this->entityManager->getRepository(User::class)->findOneBy(['npub' => $identifier]); if (!$user) { $user = new User(); $user->setNpub($identifier); $this->entityManager->persist($user); $this->entityManager->flush(); } $metadata = $this->cacheService->getMetadata($identifier); $user->setMetadata($metadata); $this->logger->debug('User metadata set.', ['metadata' => json_encode($user->getMetadata())]); return $user; } }