diff --git a/newscoop/install/index.php b/newscoop/install/index.php index 9eda133ba1..39c94c6997 100644 --- a/newscoop/install/index.php +++ b/newscoop/install/index.php @@ -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(),)); }) diff --git a/newscoop/library/Newscoop/Installer/Services/FinishService.php b/newscoop/library/Newscoop/Installer/Services/FinishService.php index b65d041dcc..52daa5c4dd 100644 --- a/newscoop/library/Newscoop/Installer/Services/FinishService.php +++ b/newscoop/library/Newscoop/Installer/Services/FinishService.php @@ -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(); diff --git a/newscoop/library/Newscoop/Tools/Console/Command/CreateOAuthClientCommand.php b/newscoop/library/Newscoop/Tools/Console/Command/CreateOAuthClientCommand.php index 1a407bca93..cd619fa31a 100644 --- a/newscoop/library/Newscoop/Tools/Console/Command/CreateOAuthClientCommand.php +++ b/newscoop/library/Newscoop/Tools/Console/Command/CreateOAuthClientCommand.php @@ -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'); } /** @@ -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)); @@ -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); }