|
@@ -0,0 +1,64 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+/*
|
|
|
+ * This file is part of Packagist.
|
|
|
+ *
|
|
|
+ * (c) Jordi Boggiano <j.boggiano@seld.be>
|
|
|
+ * Nils Adermann <naderman@naderman.de>
|
|
|
+ *
|
|
|
+ * For the full copyright and license information, please view the LICENSE
|
|
|
+ * file that was distributed with this source code.
|
|
|
+ */
|
|
|
+
|
|
|
+namespace Packagist\WebBundle\Security\Provider;
|
|
|
+
|
|
|
+use FOS\UserBundle\Model\UserManagerInterface;
|
|
|
+use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
|
|
+use Symfony\Component\Security\Core\User\UserProviderInterface;
|
|
|
+use Symfony\Component\Security\Core\User\UserInterface;
|
|
|
+
|
|
|
+class UserProvider implements UserProviderInterface
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * @var UserManagerInterface
|
|
|
+ */
|
|
|
+ private $userManager;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param UserManagerInterface $userManager
|
|
|
+ */
|
|
|
+ public function __construct(UserManagerInterface $userManager)
|
|
|
+ {
|
|
|
+ $this->userManager = $userManager;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * {@inheritDoc}
|
|
|
+ */
|
|
|
+ public function loadUserByUsername($usernameOrEmail)
|
|
|
+ {
|
|
|
+ $user = $this->userManager->findUserByUsernameOrEmail($usernameOrEmail);
|
|
|
+
|
|
|
+ if (!$user) {
|
|
|
+ throw new UsernameNotFoundException(sprintf('No user with name or email "%s" was found.', $usernameOrEmail));
|
|
|
+ }
|
|
|
+
|
|
|
+ return $user;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * {@inheritDoc}
|
|
|
+ */
|
|
|
+ public function refreshUser(UserInterface $user)
|
|
|
+ {
|
|
|
+ return $this->userManager->refreshUser($user);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * {@inheritDoc}
|
|
|
+ */
|
|
|
+ public function supportsClass($class)
|
|
|
+ {
|
|
|
+ return $this->userManager->supportsClass($class);
|
|
|
+ }
|
|
|
+}
|