aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/UserBundle
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/UserBundle')
-rw-r--r--src/Wallabag/UserBundle/Entity/User.php26
-rw-r--r--src/Wallabag/UserBundle/EventListener/CreateConfigListener.php8
-rw-r--r--src/Wallabag/UserBundle/Form/UserType.php4
-rw-r--r--src/Wallabag/UserBundle/Repository/UserRepository.php14
-rw-r--r--src/Wallabag/UserBundle/Resources/config/services.yml4
-rw-r--r--src/Wallabag/UserBundle/Resources/translations/wallabag_user.de.yml11
-rw-r--r--src/Wallabag/UserBundle/Resources/translations/wallabag_user.en.yml2
-rw-r--r--src/Wallabag/UserBundle/Resources/views/Manage/edit.html.twig8
-rw-r--r--src/Wallabag/UserBundle/Resources/views/Manage/index.html.twig2
-rw-r--r--src/Wallabag/UserBundle/Resources/views/Resetting/check_email.html.twig (renamed from src/Wallabag/UserBundle/Resources/views/Resetting/checkEmail.html.twig)2
-rw-r--r--src/Wallabag/UserBundle/Resources/views/TwoFactor/email_auth_code.html.twig2
11 files changed, 64 insertions, 19 deletions
diff --git a/src/Wallabag/UserBundle/Entity/User.php b/src/Wallabag/UserBundle/Entity/User.php
index d98ae76a..3a167de7 100644
--- a/src/Wallabag/UserBundle/Entity/User.php
+++ b/src/Wallabag/UserBundle/Entity/User.php
@@ -11,6 +11,7 @@ use JMS\Serializer\Annotation\ExclusionPolicy;
11use JMS\Serializer\Annotation\Expose; 11use JMS\Serializer\Annotation\Expose;
12use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; 12use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
13use Symfony\Component\Security\Core\User\UserInterface; 13use Symfony\Component\Security\Core\User\UserInterface;
14use Wallabag\ApiBundle\Entity\Client;
14use Wallabag\CoreBundle\Entity\Config; 15use Wallabag\CoreBundle\Entity\Config;
15use Wallabag\CoreBundle\Entity\Entry; 16use Wallabag\CoreBundle\Entity\Entry;
16 17
@@ -84,6 +85,11 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf
84 */ 85 */
85 private $trusted; 86 private $trusted;
86 87
88 /**
89 * @ORM\OneToMany(targetEntity="Wallabag\ApiBundle\Entity\Client", mappedBy="user", cascade={"remove"})
90 */
91 protected $clients;
92
87 public function __construct() 93 public function __construct()
88 { 94 {
89 parent::__construct(); 95 parent::__construct();
@@ -240,4 +246,24 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf
240 246
241 return false; 247 return false;
242 } 248 }
249
250 /**
251 * @param Client $client
252 *
253 * @return User
254 */
255 public function addClient(Client $client)
256 {
257 $this->clients[] = $client;
258
259 return $this;
260 }
261
262 /**
263 * @return ArrayCollection<Entry>
264 */
265 public function getClients()
266 {
267 return $this->clients;
268 }
243} 269}
diff --git a/src/Wallabag/UserBundle/EventListener/CreateConfigListener.php b/src/Wallabag/UserBundle/EventListener/CreateConfigListener.php
index 8e2f04e9..0bdd1cae 100644
--- a/src/Wallabag/UserBundle/EventListener/CreateConfigListener.php
+++ b/src/Wallabag/UserBundle/EventListener/CreateConfigListener.php
@@ -21,8 +21,10 @@ class CreateConfigListener implements EventSubscriberInterface
21 private $rssLimit; 21 private $rssLimit;
22 private $language; 22 private $language;
23 private $readingSpeed; 23 private $readingSpeed;
24 private $actionMarkAsRead;
25 private $listMode;
24 26
25 public function __construct(EntityManager $em, $theme, $itemsOnPage, $rssLimit, $language, $readingSpeed) 27 public function __construct(EntityManager $em, $theme, $itemsOnPage, $rssLimit, $language, $readingSpeed, $actionMarkAsRead, $listMode)
26 { 28 {
27 $this->em = $em; 29 $this->em = $em;
28 $this->theme = $theme; 30 $this->theme = $theme;
@@ -30,6 +32,8 @@ class CreateConfigListener implements EventSubscriberInterface
30 $this->rssLimit = $rssLimit; 32 $this->rssLimit = $rssLimit;
31 $this->language = $language; 33 $this->language = $language;
32 $this->readingSpeed = $readingSpeed; 34 $this->readingSpeed = $readingSpeed;
35 $this->actionMarkAsRead = $actionMarkAsRead;
36 $this->listMode = $listMode;
33 } 37 }
34 38
35 public static function getSubscribedEvents() 39 public static function getSubscribedEvents()
@@ -51,6 +55,8 @@ class CreateConfigListener implements EventSubscriberInterface
51 $config->setRssLimit($this->rssLimit); 55 $config->setRssLimit($this->rssLimit);
52 $config->setLanguage($this->language); 56 $config->setLanguage($this->language);
53 $config->setReadingSpeed($this->readingSpeed); 57 $config->setReadingSpeed($this->readingSpeed);
58 $config->setActionMarkAsRead($this->actionMarkAsRead);
59 $config->setListMode($this->listMode);
54 60
55 $this->em->persist($config); 61 $this->em->persist($config);
56 $this->em->flush(); 62 $this->em->flush();
diff --git a/src/Wallabag/UserBundle/Form/UserType.php b/src/Wallabag/UserBundle/Form/UserType.php
index cfa67793..d8cdbaf9 100644
--- a/src/Wallabag/UserBundle/Form/UserType.php
+++ b/src/Wallabag/UserBundle/Form/UserType.php
@@ -35,10 +35,6 @@ class UserType extends AbstractType
35 'required' => false, 35 'required' => false,
36 'label' => 'user.form.enabled_label', 36 'label' => 'user.form.enabled_label',
37 ]) 37 ])
38 ->add('locked', CheckboxType::class, [
39 'required' => false,
40 'label' => 'user.form.locked_label',
41 ])
42 ->add('twoFactorAuthentication', CheckboxType::class, [ 38 ->add('twoFactorAuthentication', CheckboxType::class, [
43 'required' => false, 39 'required' => false,
44 'label' => 'user.form.twofactor_label', 40 'label' => 'user.form.twofactor_label',
diff --git a/src/Wallabag/UserBundle/Repository/UserRepository.php b/src/Wallabag/UserBundle/Repository/UserRepository.php
index 009c4881..f913f52d 100644
--- a/src/Wallabag/UserBundle/Repository/UserRepository.php
+++ b/src/Wallabag/UserBundle/Repository/UserRepository.php
@@ -38,4 +38,18 @@ class UserRepository extends EntityRepository
38 ->getQuery() 38 ->getQuery()
39 ->getSingleResult(); 39 ->getSingleResult();
40 } 40 }
41
42 /**
43 * Count how many users are enabled.
44 *
45 * @return int
46 */
47 public function getSumEnabledUsers()
48 {
49 return $this->createQueryBuilder('u')
50 ->select('count(u)')
51 ->andWhere('u.enabled = true')
52 ->getQuery()
53 ->getSingleScalarResult();
54 }
41} 55}
diff --git a/src/Wallabag/UserBundle/Resources/config/services.yml b/src/Wallabag/UserBundle/Resources/config/services.yml
index a8ee721b..72f6f12c 100644
--- a/src/Wallabag/UserBundle/Resources/config/services.yml
+++ b/src/Wallabag/UserBundle/Resources/config/services.yml
@@ -22,7 +22,7 @@ services:
22 arguments: 22 arguments:
23 - WallabagUserBundle:User 23 - WallabagUserBundle:User
24 24
25 wallabag_user.create_config: 25 wallabag_user.listener.create_config:
26 class: Wallabag\UserBundle\EventListener\CreateConfigListener 26 class: Wallabag\UserBundle\EventListener\CreateConfigListener
27 arguments: 27 arguments:
28 - "@doctrine.orm.entity_manager" 28 - "@doctrine.orm.entity_manager"
@@ -31,5 +31,7 @@ services:
31 - "%wallabag_core.rss_limit%" 31 - "%wallabag_core.rss_limit%"
32 - "%wallabag_core.language%" 32 - "%wallabag_core.language%"
33 - "%wallabag_core.reading_speed%" 33 - "%wallabag_core.reading_speed%"
34 - "%wallabag_core.action_mark_as_read%"
35 - "%wallabag_core.list_mode%"
34 tags: 36 tags:
35 - { name: kernel.event_subscriber } 37 - { name: kernel.event_subscriber }
diff --git a/src/Wallabag/UserBundle/Resources/translations/wallabag_user.de.yml b/src/Wallabag/UserBundle/Resources/translations/wallabag_user.de.yml
new file mode 100644
index 00000000..4efaaab4
--- /dev/null
+++ b/src/Wallabag/UserBundle/Resources/translations/wallabag_user.de.yml
@@ -0,0 +1,11 @@
1# Two factor mail
2auth_code:
3 on: 'an'
4 mailer:
5 subject: 'wallabag Authentifizierungcode'
6 body:
7 hello: "Hi %user%,"
8 first_para: "da du die Zwei-Faktor-Authentifizierung in deinem wallabag Konto aktiviert hast, und du dich gerade von einem neuen Gerät (Computer, Handy, etc.) anmeldest, senden wir dir einen Code, um deinen Zugriff zu prüfen."
9 second_para: "Hier ist der Code:"
10 support: "Bitte zögere nicht, Kontakt mit uns aufzunehmen falls du ein Problem hast:"
11 signature: "Das wallabag Team"
diff --git a/src/Wallabag/UserBundle/Resources/translations/wallabag_user.en.yml b/src/Wallabag/UserBundle/Resources/translations/wallabag_user.en.yml
index 85f2ea9c..ee0a27d5 100644
--- a/src/Wallabag/UserBundle/Resources/translations/wallabag_user.en.yml
+++ b/src/Wallabag/UserBundle/Resources/translations/wallabag_user.en.yml
@@ -2,7 +2,7 @@
2auth_code: 2auth_code:
3 on: 'on' 3 on: 'on'
4 mailer: 4 mailer:
5 subject: 'Wallabag authentication Code' 5 subject: 'wallabag authentication code'
6 body: 6 body:
7 hello: "Hi %user%," 7 hello: "Hi %user%,"
8 first_para: "Since you enable two factor authentication on your wallabag account and you just logged in from a new device (computer, phone, etc.), we send you a code to validate your connection." 8 first_para: "Since you enable two factor authentication on your wallabag account and you just logged in from a new device (computer, phone, etc.), we send you a code to validate your connection."
diff --git a/src/Wallabag/UserBundle/Resources/views/Manage/edit.html.twig b/src/Wallabag/UserBundle/Resources/views/Manage/edit.html.twig
index 67843f20..3ffd15f5 100644
--- a/src/Wallabag/UserBundle/Resources/views/Manage/edit.html.twig
+++ b/src/Wallabag/UserBundle/Resources/views/Manage/edit.html.twig
@@ -47,14 +47,6 @@
47 </div> 47 </div>
48 </div> 48 </div>
49 49
50 <div class="row">
51 <div class="input-field col s12">
52 {{ form_widget(edit_form.locked) }}
53 {{ form_label(edit_form.locked) }}
54 {{ form_errors(edit_form.locked) }}
55 </div>
56 </div>
57
58 {% if twofactor_auth %} 50 {% if twofactor_auth %}
59 <div class="row"> 51 <div class="row">
60 <div class="input-field col s12"> 52 <div class="input-field col s12">
diff --git a/src/Wallabag/UserBundle/Resources/views/Manage/index.html.twig b/src/Wallabag/UserBundle/Resources/views/Manage/index.html.twig
index 996bdb1a..daba29e4 100644
--- a/src/Wallabag/UserBundle/Resources/views/Manage/index.html.twig
+++ b/src/Wallabag/UserBundle/Resources/views/Manage/index.html.twig
@@ -17,7 +17,6 @@
17 <th>{{ 'user.form.username_label'|trans }}</th> 17 <th>{{ 'user.form.username_label'|trans }}</th>
18 <th>{{ 'user.form.email_label'|trans }}</th> 18 <th>{{ 'user.form.email_label'|trans }}</th>
19 <th>{{ 'user.form.last_login_label'|trans }}</th> 19 <th>{{ 'user.form.last_login_label'|trans }}</th>
20 <th>{{ 'user.form.locked_label'|trans }}</th>
21 <th>{{ 'user.list.actions'|trans }}</th> 20 <th>{{ 'user.list.actions'|trans }}</th>
22 </tr> 21 </tr>
23 </thead> 22 </thead>
@@ -27,7 +26,6 @@
27 <td>{{ user.username }}</td> 26 <td>{{ user.username }}</td>
28 <td>{{ user.email }}</td> 27 <td>{{ user.email }}</td>
29 <td>{% if user.lastLogin %}{{ user.lastLogin|date('Y-m-d H:i:s') }}{% endif %}</td> 28 <td>{% if user.lastLogin %}{{ user.lastLogin|date('Y-m-d H:i:s') }}{% endif %}</td>
30 <td>{% if user.locked %}{{ 'user.list.yes'|trans }}{% else %}{{ 'user.list.no'|trans }}{% endif %}</td>
31 <td> 29 <td>
32 <a href="{{ path('user_edit', { 'id': user.id }) }}">{{ 'user.list.edit_action'|trans }}</a> 30 <a href="{{ path('user_edit', { 'id': user.id }) }}">{{ 'user.list.edit_action'|trans }}</a>
33 </td> 31 </td>
diff --git a/src/Wallabag/UserBundle/Resources/views/Resetting/checkEmail.html.twig b/src/Wallabag/UserBundle/Resources/views/Resetting/check_email.html.twig
index 66cbdc28..e9d46dcc 100644
--- a/src/Wallabag/UserBundle/Resources/views/Resetting/checkEmail.html.twig
+++ b/src/Wallabag/UserBundle/Resources/views/Resetting/check_email.html.twig
@@ -5,7 +5,7 @@
5{% block fos_user_content %} 5{% block fos_user_content %}
6<div class="card-content"> 6<div class="card-content">
7 <div class="row"> 7 <div class="row">
8 {{ 'resetting.check_email'|trans({'%email%': email}) }} 8 <p>{{ 'resetting.check_email'|trans({'%tokenLifetime%': tokenLifetime}) }}</p>
9 </div> 9 </div>
10</div> 10</div>
11{% endblock fos_user_content %} 11{% endblock fos_user_content %}
diff --git a/src/Wallabag/UserBundle/Resources/views/TwoFactor/email_auth_code.html.twig b/src/Wallabag/UserBundle/Resources/views/TwoFactor/email_auth_code.html.twig
index 3731f13b..5d1f22b7 100644
--- a/src/Wallabag/UserBundle/Resources/views/TwoFactor/email_auth_code.html.twig
+++ b/src/Wallabag/UserBundle/Resources/views/TwoFactor/email_auth_code.html.twig
@@ -74,7 +74,7 @@
74 74
75 <table cellpadding="0" cellspacing="0" border="0" align="center" id="card"> 75 <table cellpadding="0" cellspacing="0" border="0" align="center" id="card">
76 <tr> 76 <tr>
77 <td style="padding: 20px;" width="96px" valign="top"><img class="image_fix" src="{{ asset('bundles/wallabagcore/themes/material/img/logo-other_themes.png') }}" alt="logo" title="{{ wallabag_url }}" style="width: 96px; height: 96px;" /></td> 77 <td style="padding: 20px;" width="96px" valign="top"><img class="image_fix" src="{{ absolute_url(asset('bundles/wallabagcore/themes/_global/img/logo-other_themes.png')) }}" alt="logo" title="{{ wallabag_url }}" style="width: 96px; height: 96px;" /></td>
78 <td style="padding: 20px; padding-left: 0;" valign="top" id="cell_desc"> 78 <td style="padding: 20px; padding-left: 0;" valign="top" id="cell_desc">
79 <h1>wallabag</h1> 79 <h1>wallabag</h1>
80 <h5>{{ "auth_code.on"|trans({}, 'wallabag_user') }} {{ wallabag_url }}</h5> 80 <h5>{{ "auth_code.on"|trans({}, 'wallabag_user') }} {{ wallabag_url }}</h5>