Skip to content

Commit

Permalink
[KunstmaanAdminBundle]: access level for google should add groups
Browse files Browse the repository at this point in the history
  • Loading branch information
sandergo90 committed Mar 13, 2018
1 parent a6e7c2d commit b572cc7
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
namespace Kunstmaan\AdminBundle\Helper\Security\OAuth;

use Doctrine\ORM\EntityManagerInterface;
use FOS\UserBundle\Model\GroupInterface;
use Kunstmaan\AdminBundle\Entity\User;

class OAuthUserCreator implements OAuthUserCreatorInterface
{
/** @var EntityManager */
/** @var EntityManagerInterface */
private $em;

/** @var array */
Expand All @@ -21,9 +22,10 @@ class OAuthUserCreator implements OAuthUserCreatorInterface

/**
* OAuthUserCreator constructor.
*
* @param EntityManagerInterface $em
* @param $hostedDomains
* @param $userClass
* @param array $hostedDomains
* @param string $userClass
* @param OAuthUserFinderInterface $userFinder
*/
public function __construct(EntityManagerInterface $em, $hostedDomains, $userClass, OAuthUserFinderInterface $userFinder)
Expand Down Expand Up @@ -56,7 +58,11 @@ public function getOrCreateUser($email, $googleId)
}

foreach ($this->getAccessLevels($email) as $accessLevel) {
$user->addRole($accessLevel);
/** @var GroupInterface $group */
$group = $this->em->getRepository('KunstmaanAdminBundle:Group')->findOneBy(['name' => $accessLevel]);
if (null !== $group) {
$user->addGroup($group);
}
}
$user->setGoogleId($googleId);

Expand Down

0 comments on commit b572cc7

Please sign in to comment.