Skip to content

Commit

Permalink
CS-5678: create default oauth client - fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ahilles107 committed Feb 24, 2015
1 parent 8794fb9 commit 5baefe0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion newscoop/install/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@
$app['finish_service']->generateProxies();
$app['finish_service']->installAssets();
$app['finish_service']->saveInstanceConfig($app['session']->get('main_config'), $app['db']);
$app['finish_service']->createDefaultOauthCleint();
$app['finish_service']->createDefaultOauthClient();

return $app['twig']->render('post-process.twig', array('NewscoopVersion' => new \CampVersion(),));
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public function generateProxies()
}

/**
* Reload themes reditions in datbase
* Create default oauth client
*/
public function createDefaultOauthCleint()
public function createDefaultOauthClient()
{
$phpFinder = new PhpExecutableFinder();
$phpPath = $phpFinder->find();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ protected function configure()
->addArgument('name', InputArgument::REQUIRED, 'Client name')
->addArgument('publication', InputArgument::REQUIRED, 'Publication alias')
->addArgument('redirectUris', InputArgument::REQUIRED, 'Redirect uris')
->addOption('test', null, InputOption::VALUE_NONE, 'If set it will create test client with predefnied data (for automatic tests)')
->addOption('default', null, InputOption::VALUE_NONE, 'If set it will create default client with predefnied name');
->addOption('test', null, InputOption::VALUE_NONE, 'If set it will create test client with predefined data (for automatic tests)')
->addOption('default', null, InputOption::VALUE_NONE, 'If set it will create default client with predefined name');
}

/**
Expand All @@ -49,6 +49,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
->getPublication();
$redirectUris = $input->getArgument('redirectUris');

if ($input->getOption('default')) {
$preferencesService = $container->get('preferences');
$defaultClientName = 'newscoop_'.$preferencesService->SiteSecretKey;
$client = $em->getRepository('\Newscoop\GimmeBundle\Entity\Client')->findOneByName($defaultClientName);
if ($client) {
return;
}
}

$client = $clientManager->createClient();
$client->setAllowedGrantTypes(array('token', 'authorization_code', 'client_credentials', 'password'));
$client->setRedirectUris(array($redirectUris));
Expand All @@ -62,9 +71,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

if ($input->getOption('default')) {
$preferencesService = $container->get('preferences');
$clientName = 'newscoop_'.$preferencesService->SiteSecretKey;
$client->setName($clientName);
$client->setName($defaultClientName);
$client->setTrusted(true);
}

Expand Down

0 comments on commit 5baefe0

Please sign in to comment.