aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/ImportBundle')
-rw-r--r--src/Wallabag/ImportBundle/Command/ImportCommand.php17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/Wallabag/ImportBundle/Command/ImportCommand.php b/src/Wallabag/ImportBundle/Command/ImportCommand.php
index f9ffe994..26903e9c 100644
--- a/src/Wallabag/ImportBundle/Command/ImportCommand.php
+++ b/src/Wallabag/ImportBundle/Command/ImportCommand.php
@@ -8,6 +8,7 @@ use Symfony\Component\Console\Input\InputArgument;
8use Symfony\Component\Console\Input\InputInterface; 8use Symfony\Component\Console\Input\InputInterface;
9use Symfony\Component\Console\Input\InputOption; 9use Symfony\Component\Console\Input\InputOption;
10use Symfony\Component\Console\Output\OutputInterface; 10use Symfony\Component\Console\Output\OutputInterface;
11use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
11 12
12class ImportCommand extends ContainerAwareCommand 13class ImportCommand extends ContainerAwareCommand
13{ 14{
@@ -38,15 +39,25 @@ class ImportCommand extends ContainerAwareCommand
38 $em->getConnection()->getConfiguration()->setSQLLogger(null); 39 $em->getConnection()->getConfiguration()->setSQLLogger(null);
39 40
40 if ($input->getOption('useUserId')) { 41 if ($input->getOption('useUserId')) {
41 $user = $em->getRepository('WallabagUserBundle:User')->findOneById($input->getArgument('username')); 42 $entityUser = $em->getRepository('WallabagUserBundle:User')->findOneById($input->getArgument('username'));
42 } else { 43 } else {
43 $user = $em->getRepository('WallabagUserBundle:User')->findOneByUsername($input->getArgument('username')); 44 $entityUser = $em->getRepository('WallabagUserBundle:User')->findOneByUsername($input->getArgument('username'));
44 } 45 }
45 46
46 if (!\is_object($user)) { 47 if (!\is_object($entityUser)) {
47 throw new Exception(sprintf('User "%s" not found', $input->getArgument('username'))); 48 throw new Exception(sprintf('User "%s" not found', $input->getArgument('username')));
48 } 49 }
49 50
51 // Authenticate user for paywalled websites
52 $token = new UsernamePasswordToken(
53 $entityUser,
54 null,
55 'main',
56 $entityUser->getRoles());
57
58 $this->getContainer()->get('security.token_storage')->setToken($token);
59 $user = $this->getContainer()->get('security.token_storage')->getToken()->getUser();
60
50 switch ($input->getOption('importer')) { 61 switch ($input->getOption('importer')) {
51 case 'v2': 62 case 'v2':
52 $import = $this->getContainer()->get('wallabag_import.wallabag_v2.import'); 63 $import = $this->getContainer()->get('wallabag_import.wallabag_v2.import');