|
@@ -58,20 +58,29 @@ class OAuthClientCreateRedirectsCommand extends ContainerAwareCommand
|
|
|
$clientManager = $this->getContainer()->get('fos_oauth_server.client_manager.default');
|
|
|
|
|
|
$em = $this->getContainer()->get('doctrine')->getEntityManager();
|
|
|
- /* @var $client OAuthClient */
|
|
|
- $client = $clientManager->createClient();
|
|
|
- if ($random) {
|
|
|
- $client->setRandomId($random);
|
|
|
+ $newUri = [];
|
|
|
+ foreach ($redirectUri as $uri) {
|
|
|
+ $client = $em->getRepository('BaseOAuthServerBundle:OAuthClient')->findOneByRedirectUri($uri);
|
|
|
+ if (!$client) {
|
|
|
+ // agrego las uri que no estan cargadas en la tabla
|
|
|
+ $newUri[] = $uri;
|
|
|
+ }
|
|
|
}
|
|
|
- if ($secret) {
|
|
|
- $client->setSecret($secret);
|
|
|
+ if (count($newUri) > 0) {
|
|
|
+ /* @var $client OAuthClient */
|
|
|
+ $client = $clientManager->createClient();
|
|
|
+ if ($random) {
|
|
|
+ $client->setRandomId($random);
|
|
|
+ }
|
|
|
+ if ($secret) {
|
|
|
+ $client->setSecret($secret);
|
|
|
+ }
|
|
|
+ $client->setRedirectUris(
|
|
|
+ $newUri
|
|
|
+ );
|
|
|
+ $client->setAllowedGrantTypes(array_keys(OAuthClient::getGrantTypesChoices()));
|
|
|
+ $clientManager->updateClient($client);
|
|
|
}
|
|
|
- $client->setRedirectUris(
|
|
|
- $redirectUri
|
|
|
- );
|
|
|
- $client->setAllowedGrantTypes(array_keys(OAuthClient::getGrantTypesChoices()));
|
|
|
- $clientManager->updateClient($client);
|
|
|
-
|
|
|
return $client;
|
|
|
}
|
|
|
|