public function onPostAuthorizationProcess(OAuthEvent $event) { if (!$event->isAuthorizedClient()) { return; } if (null === ($client = $event->getClient())) { return; } $user = $this->getUser($event); $scope = $this->getScope(); $em = $this->doctrine->getManager(); $authRepo = $em->getRepository('LoginCidadaoCoreBundle:Authorization'); $currentAuth = $authRepo->findOneBy(array('person' => $user, 'client' => $client)); // if the authorization is already there, update it. if ($currentAuth instanceof Authorization) { $merged = array_merge($currentAuth->getScope(), $scope); $currentAuth->setScope($merged); } else { $authorization = new Authorization(); $authorization->setClient($client); $authorization->setPerson($user); $authorization->setScope($scope); $em->persist($authorization); } $em->flush(); }
public function onPostAuthorizationProcess(OAuthEvent $event) { if ($event->isAuthorizedClient()) { if (null !== ($client = $event->getClient())) { $this->setupNotificationSettings($event); } } }
public function onPostAuthorizationProcess(OAuthEvent $event) { if ($event->isAuthorizedClient()) { if (null !== ($client = $event->getClient())) { $user = $this->getUser($event); $user->addOauthClient($client); $this->em->flush(); } } }
public function onPostAuthorizationProcess(OAuthEvent $event) { if ($event->isAuthorizedClient() && null !== ($client = $event->getClient())) { $repo = $this->entityManager->getRepository('ActsCamdramApiBundle:Authorization'); if ($auth = $repo->findOne($event->getUser(), $event->getClient())) { $auth->addScopes($this->getScopes()); $this->entityManager->flush(); } else { /** @var User $user */ $auth = new Authorization(); $auth->setClient($event->getClient())->setUser($event->getUser())->setScopes($this->getScopes()); $this->entityManager->persist($auth); $this->entityManager->flush(); } } }