aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php12
-rw-r--r--src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php8
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.da.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.de.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.en.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.es.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.it.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.th.yml2
-rw-r--r--tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php18
15 files changed, 36 insertions, 26 deletions
diff --git a/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php b/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php
index 90e00c62..718441bd 100644
--- a/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php
+++ b/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php
@@ -64,7 +64,17 @@ class GrabySiteConfigBuilder implements SiteConfigBuilder
64 64
65 $credentials = null; 65 $credentials = null;
66 if ($this->currentUser) { 66 if ($this->currentUser) {
67 $credentials = $this->credentialRepository->findOneByHostAndUser($host, $this->currentUser->getId()); 67 $hosts = [$host];
68 // will try to see for a host without the first subdomain (fr.example.org & .example.org)
69 $split = explode('.', $host);
70
71 if (\count($split) > 1) {
72 // remove first subdomain
73 array_shift($split);
74 $hosts[] = '.' . implode('.', $split);
75 }
76
77 $credentials = $this->credentialRepository->findOneByHostsAndUser($hosts, $this->currentUser->getId());
68 } 78 }
69 79
70 if (null === $credentials) { 80 if (null === $credentials) {
diff --git a/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php b/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php
index b2e212a4..aeadd770 100644
--- a/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php
@@ -19,16 +19,16 @@ class SiteCredentialRepository extends \Doctrine\ORM\EntityRepository
19 /** 19 /**
20 * Retrieve one username/password for the given host and userId. 20 * Retrieve one username/password for the given host and userId.
21 * 21 *
22 * @param string $host 22 * @param array $hosts An array of host to look for
23 * @param int $userId 23 * @param int $userId
24 * 24 *
25 * @return array|null 25 * @return array|null
26 */ 26 */
27 public function findOneByHostAndUser($host, $userId) 27 public function findOneByHostsAndUser($hosts, $userId)
28 { 28 {
29 $res = $this->createQueryBuilder('s') 29 $res = $this->createQueryBuilder('s')
30 ->select('s.username', 's.password') 30 ->select('s.username', 's.password')
31 ->where('s.host = :hostname')->setParameter('hostname', $host) 31 ->where('s.host IN (:hosts)')->setParameter('hosts', $hosts)
32 ->andWhere('s.user = :userId')->setParameter('userId', $userId) 32 ->andWhere('s.user = :userId')->setParameter('userId', $userId)
33 ->setMaxResults(1) 33 ->setMaxResults(1)
34 ->getQuery() 34 ->getQuery()
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
index 97eb874d..6f842534 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
@@ -550,7 +550,7 @@ site_credential:
550 # create_new_one: Create a new credential 550 # create_new_one: Create a new credential
551 # form: 551 # form:
552 # username_label: 'Username' 552 # username_label: 'Username'
553 # host_label: 'Host' 553 # host_label: 'Host (subdomain.example.org, .example.org, etc.)'
554 # password_label: 'Password' 554 # password_label: 'Password'
555 # save: Save 555 # save: Save
556 # delete: Delete 556 # delete: Delete
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
index 0cf3b138..874908b9 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
@@ -550,7 +550,7 @@ site_credential:
550 create_new_one: 'Einen neuen Seitenzugang anlegen' 550 create_new_one: 'Einen neuen Seitenzugang anlegen'
551 form: 551 form:
552 username_label: 'Benutzername' 552 username_label: 'Benutzername'
553 host_label: 'Host' 553 host_label: 'Host (subdomain.example.org, .example.org, etc.)'
554 password_label: 'Passwort' 554 password_label: 'Passwort'
555 save: 'Speichern' 555 save: 'Speichern'
556 delete: 'Löschen' 556 delete: 'Löschen'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
index 6085be14..598ad58d 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
@@ -550,7 +550,7 @@ site_credential:
550 create_new_one: Create a new credential 550 create_new_one: Create a new credential
551 form: 551 form:
552 username_label: 'Username' 552 username_label: 'Username'
553 host_label: 'Host' 553 host_label: 'Host (subdomain.example.org, .example.org, etc.)'
554 password_label: 'Password' 554 password_label: 'Password'
555 save: Save 555 save: Save
556 delete: Delete 556 delete: Delete
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
index f2a8fb89..f8aa4109 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
@@ -550,7 +550,7 @@ site_credential:
550 # create_new_one: Create a new credential 550 # create_new_one: Create a new credential
551 # form: 551 # form:
552 # username_label: 'Username' 552 # username_label: 'Username'
553 # host_label: 'Host' 553 # host_label: 'Host (subdomain.example.org, .example.org, etc.)'
554 # password_label: 'Password' 554 # password_label: 'Password'
555 # save: Save 555 # save: Save
556 # delete: Delete 556 # delete: Delete
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
index a5cbd7ec..785e39ee 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
@@ -550,7 +550,7 @@ site_credential:
550 # create_new_one: Create a new credential 550 # create_new_one: Create a new credential
551 # form: 551 # form:
552 # username_label: 'Username' 552 # username_label: 'Username'
553 # host_label: 'Host' 553 # host_label: 'Host (subdomain.example.org, .example.org, etc.)'
554 # password_label: 'Password' 554 # password_label: 'Password'
555 # save: Save 555 # save: Save
556 # delete: Delete 556 # delete: Delete
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
index a36d84ae..b2fa1c50 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
@@ -550,7 +550,7 @@ site_credential:
550 create_new_one: Créer un nouvel accès à un site 550 create_new_one: Créer un nouvel accès à un site
551 form: 551 form:
552 username_label: 'Identifiant' 552 username_label: 'Identifiant'
553 host_label: 'Domaine' 553 host_label: 'Domaine (subdomain.example.org, .example.org, etc.)'
554 password_label: 'Mot de passe' 554 password_label: 'Mot de passe'
555 save: "Sauvegarder" 555 save: "Sauvegarder"
556 delete: "Supprimer" 556 delete: "Supprimer"
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
index 1649c0e4..ecaa3b60 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
@@ -550,7 +550,7 @@ site_credential:
550 # create_new_one: Create a new credential 550 # create_new_one: Create a new credential
551 # form: 551 # form:
552 # username_label: 'Username' 552 # username_label: 'Username'
553 # host_label: 'Host' 553 # host_label: 'Host (subdomain.example.org, .example.org, etc.)'
554 # password_label: 'Password' 554 # password_label: 'Password'
555 # save: Save 555 # save: Save
556 # delete: Delete 556 # delete: Delete
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
index e2298f1f..848c88d2 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
@@ -550,7 +550,7 @@ site_credential:
550 create_new_one: Crear un novèl identificant 550 create_new_one: Crear un novèl identificant
551 form: 551 form:
552 username_label: "Nom d'utilizaire" 552 username_label: "Nom d'utilizaire"
553 host_label: 'Òste' 553 host_label: 'Òste (subdomain.example.org, .example.org, etc.)'
554 password_label: 'Senhal' 554 password_label: 'Senhal'
555 save: 'Enregistrar' 555 save: 'Enregistrar'
556 delete: 'Suprimir' 556 delete: 'Suprimir'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
index a5712733..a0032fe8 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
@@ -550,7 +550,7 @@ site_credential:
550 create_new_one: Stwórz nowe poświadczenie 550 create_new_one: Stwórz nowe poświadczenie
551 form: 551 form:
552 username_label: 'Nazwa użytkownika' 552 username_label: 'Nazwa użytkownika'
553 host_label: 'Host' 553 host_label: 'Host (subdomain.example.org, .example.org, etc.)'
554 password_label: 'Hasło' 554 password_label: 'Hasło'
555 save: Zapisz 555 save: Zapisz
556 delete: Usuń 556 delete: Usuń
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml
index 1ccf49e1..292fad61 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml
@@ -550,7 +550,7 @@ site_credential:
550 # create_new_one: Create a new credential 550 # create_new_one: Create a new credential
551 form: 551 form:
552 # username_label: 'Username' 552 # username_label: 'Username'
553 # host_label: 'Host' 553 # host_label: 'Host (subdomain.example.org, .example.org, etc.)'
554 # password_label: 'Password' 554 # password_label: 'Password'
555 save: 'Salvar' 555 save: 'Salvar'
556 delete: 'Apagar' 556 delete: 'Apagar'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
index 6c0e18e1..9e8d68b3 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
@@ -550,7 +550,7 @@ site_credential:
550 # create_new_one: Create a new credential 550 # create_new_one: Create a new credential
551 # form: 551 # form:
552 # username_label: 'Username' 552 # username_label: 'Username'
553 # host_label: 'Host' 553 # host_label: 'Host (subdomain.example.org, .example.org, etc.)'
554 # password_label: 'Password' 554 # password_label: 'Password'
555 # save: Save 555 # save: Save
556 # delete: Delete 556 # delete: Delete
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml
index 5524b1f1..cb3b0f23 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml
@@ -548,7 +548,7 @@ site_credential:
548 create_new_one: สร้างข้อมูลส่วนตัวใหม่ 548 create_new_one: สร้างข้อมูลส่วนตัวใหม่
549 form: 549 form:
550 username_label: 'ชื่อผู้ใช้' 550 username_label: 'ชื่อผู้ใช้'
551 host_label: 'โฮส' 551 host_label: 'โฮส (subdomain.example.org, .example.org, etc.)'
552 password_label: 'รหัสผ่าน' 552 password_label: 'รหัสผ่าน'
553 save: บันทึก 553 save: บันทึก
554 delete: ลบ 554 delete: ลบ
diff --git a/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php b/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php
index 1173fc3d..90609180 100644
--- a/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php
+++ b/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php
@@ -24,7 +24,7 @@ class GrabySiteConfigBuilderTest extends TestCase
24 24
25 $grabySiteConfig = new GrabySiteConfig(); 25 $grabySiteConfig = new GrabySiteConfig();
26 $grabySiteConfig->requires_login = true; 26 $grabySiteConfig->requires_login = true;
27 $grabySiteConfig->login_uri = 'http://www.example.com/login'; 27 $grabySiteConfig->login_uri = 'http://api.example.com/login';
28 $grabySiteConfig->login_username_field = 'login'; 28 $grabySiteConfig->login_username_field = 'login';
29 $grabySiteConfig->login_password_field = 'password'; 29 $grabySiteConfig->login_password_field = 'password';
30 $grabySiteConfig->login_extra_fields = ['field=value']; 30 $grabySiteConfig->login_extra_fields = ['field=value'];
@@ -32,7 +32,7 @@ class GrabySiteConfigBuilderTest extends TestCase
32 32
33 $grabyConfigBuilderMock 33 $grabyConfigBuilderMock
34 ->method('buildForHost') 34 ->method('buildForHost')
35 ->with('example.com') 35 ->with('api.example.com')
36 ->will($this->returnValue($grabySiteConfig)); 36 ->will($this->returnValue($grabySiteConfig));
37 37
38 $logger = new Logger('foo'); 38 $logger = new Logger('foo');
@@ -43,8 +43,8 @@ class GrabySiteConfigBuilderTest extends TestCase
43 ->disableOriginalConstructor() 43 ->disableOriginalConstructor()
44 ->getMock(); 44 ->getMock();
45 $siteCrentialRepo->expects($this->once()) 45 $siteCrentialRepo->expects($this->once())
46 ->method('findOneByHostAndUser') 46 ->method('findOneByHostsAndUser')
47 ->with('example.com', 1) 47 ->with(['api.example.com', '.example.com'], 1)
48 ->willReturn(['username' => 'foo', 'password' => 'bar']); 48 ->willReturn(['username' => 'foo', 'password' => 'bar']);
49 49
50 $user = $this->getMockBuilder('Wallabag\UserBundle\Entity\User') 50 $user = $this->getMockBuilder('Wallabag\UserBundle\Entity\User')
@@ -66,11 +66,11 @@ class GrabySiteConfigBuilderTest extends TestCase
66 $logger 66 $logger
67 ); 67 );
68 68
69 $config = $this->builder->buildForHost('www.example.com'); 69 $config = $this->builder->buildForHost('api.example.com');
70 70
71 $this->assertSame('example.com', $config->getHost()); 71 $this->assertSame('api.example.com', $config->getHost());
72 $this->assertTrue($config->requiresLogin()); 72 $this->assertTrue($config->requiresLogin());
73 $this->assertSame('http://www.example.com/login', $config->getLoginUri()); 73 $this->assertSame('http://api.example.com/login', $config->getLoginUri());
74 $this->assertSame('login', $config->getUsernameField()); 74 $this->assertSame('login', $config->getUsernameField());
75 $this->assertSame('password', $config->getPasswordField()); 75 $this->assertSame('password', $config->getPasswordField());
76 $this->assertSame(['field' => 'value'], $config->getExtraFields()); 76 $this->assertSame(['field' => 'value'], $config->getExtraFields());
@@ -103,8 +103,8 @@ class GrabySiteConfigBuilderTest extends TestCase
103 ->disableOriginalConstructor() 103 ->disableOriginalConstructor()
104 ->getMock(); 104 ->getMock();
105 $siteCrentialRepo->expects($this->once()) 105 $siteCrentialRepo->expects($this->once())
106 ->method('findOneByHostAndUser') 106 ->method('findOneByHostsAndUser')
107 ->with('unknown.com', 1) 107 ->with(['unknown.com', '.com'], 1)
108 ->willReturn(null); 108 ->willReturn(null);
109 109
110 $user = $this->getMockBuilder('Wallabag\UserBundle\Entity\User') 110 $user = $this->getMockBuilder('Wallabag\UserBundle\Entity\User')