aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNicolas Lœuillet <nicolas@loeuillet.org>2020-04-14 19:59:54 +0200
committerGitHub <noreply@github.com>2020-04-14 19:59:54 +0200
commit35359a23c1308ed7fd943de9f7018cabf83b21e4 (patch)
tree620914990d017b64bd2dda603b7af4a2be120c5f
parent2b21cc8869c9a6cbcc14a10aa6f39a10c3b8c4a0 (diff)
parente349c879faafdd3d8f61aebb257c4c89ccd3da7d (diff)
downloadwallabag-35359a23c1308ed7fd943de9f7018cabf83b21e4.tar.gz
wallabag-35359a23c1308ed7fd943de9f7018cabf83b21e4.tar.zst
wallabag-35359a23c1308ed7fd943de9f7018cabf83b21e4.zip
Merge pull request #4329 from wallabag/add-2fa-disable
Added a button to disable 2FA when enabled
-rw-r--r--src/Wallabag/CoreBundle/Controller/ConfigController.php55
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.da.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.de.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.en.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.es.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.it.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.ja.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.th.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.zh.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig4
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig4
-rw-r--r--tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php47
20 files changed, 122 insertions, 4 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php
index 6655ef93..56efe82b 100644
--- a/src/Wallabag/CoreBundle/Controller/ConfigController.php
+++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php
@@ -193,6 +193,30 @@ class ConfigController extends Controller
193 } 193 }
194 194
195 /** 195 /**
196 * Disable 2FA using email.
197 *
198 * @Route("/config/otp/email/disable", name="disable_otp_email")
199 */
200 public function disableOtpEmailAction()
201 {
202 if (!$this->getParameter('twofactor_auth')) {
203 return $this->createNotFoundException('two_factor not enabled');
204 }
205
206 $user = $this->getUser();
207 $user->setEmailTwoFactor(false);
208
209 $this->container->get('fos_user.user_manager')->updateUser($user, true);
210
211 $this->addFlash(
212 'notice',
213 'flashes.config.notice.otp_disabled'
214 );
215
216 return $this->redirect($this->generateUrl('config') . '#set3');
217 }
218
219 /**
196 * Enable 2FA using email. 220 * Enable 2FA using email.
197 * 221 *
198 * @Route("/config/otp/email", name="config_otp_email") 222 * @Route("/config/otp/email", name="config_otp_email")
@@ -220,6 +244,32 @@ class ConfigController extends Controller
220 } 244 }
221 245
222 /** 246 /**
247 * Disable 2FA using OTP app.
248 *
249 * @Route("/config/otp/app/disable", name="disable_otp_app")
250 */
251 public function disableOtpAppAction()
252 {
253 if (!$this->getParameter('twofactor_auth')) {
254 return $this->createNotFoundException('two_factor not enabled');
255 }
256
257 $user = $this->getUser();
258
259 $user->setGoogleAuthenticatorSecret('');
260 $user->setBackupCodes(null);
261
262 $this->container->get('fos_user.user_manager')->updateUser($user, true);
263
264 $this->addFlash(
265 'notice',
266 'flashes.config.notice.otp_disabled'
267 );
268
269 return $this->redirect($this->generateUrl('config') . '#set3');
270 }
271
272 /**
223 * Enable 2FA using OTP app, user will need to confirm the generated code from the app. 273 * Enable 2FA using OTP app, user will need to confirm the generated code from the app.
224 * 274 *
225 * @Route("/config/otp/app", name="config_otp_app") 275 * @Route("/config/otp/app", name="config_otp_app")
@@ -248,6 +298,11 @@ class ConfigController extends Controller
248 298
249 $this->container->get('fos_user.user_manager')->updateUser($user, true); 299 $this->container->get('fos_user.user_manager')->updateUser($user, true);
250 300
301 $this->addFlash(
302 'notice',
303 'flashes.config.notice.otp_enabled'
304 );
305
251 return $this->render('WallabagCoreBundle:Config:otp_app.html.twig', [ 306 return $this->render('WallabagCoreBundle:Config:otp_app.html.twig', [
252 'backupCodes' => $backupCodes, 307 'backupCodes' => $backupCodes,
253 'qr_code' => $this->get('scheb_two_factor.security.google_authenticator')->getQRContent($user), 308 'qr_code' => $this->get('scheb_two_factor.security.google_authenticator')->getQRContent($user),
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
index 53b60c72..fc43e9fd 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
@@ -613,6 +613,7 @@ flashes:
613 # entries_reset: Entries reset 613 # entries_reset: Entries reset
614 # archived_reset: Archived entries deleted 614 # archived_reset: Archived entries deleted
615 # otp_enabled: Two-factor authentication enabled 615 # otp_enabled: Two-factor authentication enabled
616 # otp_disabled: Two-factor authentication disabled
616 # tagging_rules_imported: Tagging rules imported 617 # tagging_rules_imported: Tagging rules imported
617 # tagging_rules_not_imported: Error while importing tagging rules 618 # tagging_rules_not_imported: Error while importing tagging rules
618 entry: 619 entry:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
index b9694be8..53c960b6 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
@@ -613,6 +613,7 @@ flashes:
613 entries_reset: Einträge zurücksetzen 613 entries_reset: Einträge zurücksetzen
614 archived_reset: Archiverte Einträge zurücksetzen 614 archived_reset: Archiverte Einträge zurücksetzen
615 # otp_enabled: Two-factor authentication enabled 615 # otp_enabled: Two-factor authentication enabled
616 # otp_disabled: Two-factor authentication disabled
616 # tagging_rules_imported: Tagging rules imported 617 # tagging_rules_imported: Tagging rules imported
617 # tagging_rules_not_imported: Error while importing tagging rules 618 # tagging_rules_not_imported: Error while importing tagging rules
618 entry: 619 entry:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
index e8b1ea15..c6e3cd42 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
@@ -613,6 +613,7 @@ flashes:
613 entries_reset: Entries reset 613 entries_reset: Entries reset
614 archived_reset: Archived entries deleted 614 archived_reset: Archived entries deleted
615 otp_enabled: Two-factor authentication enabled 615 otp_enabled: Two-factor authentication enabled
616 otp_disabled: Two-factor authentication disabled
616 tagging_rules_imported: Tagging rules imported 617 tagging_rules_imported: Tagging rules imported
617 tagging_rules_not_imported: Error while importing tagging rules 618 tagging_rules_not_imported: Error while importing tagging rules
618 entry: 619 entry:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
index 6fd44f8e..72e36449 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
@@ -613,6 +613,7 @@ flashes:
613 entries_reset: Artículos reiniciados 613 entries_reset: Artículos reiniciados
614 archived_reset: Artículos archivados borrados 614 archived_reset: Artículos archivados borrados
615 otp_enabled: Autenticación de dos pasos activada 615 otp_enabled: Autenticación de dos pasos activada
616 # otp_disabled: Two-factor authentication disabled
616 tagging_rules_imported: Reglas de etiquetado importadas 617 tagging_rules_imported: Reglas de etiquetado importadas
617 tagging_rules_not_imported: Un error se ha producico en la importación de las reglas de etiquetado 618 tagging_rules_not_imported: Un error se ha producico en la importación de las reglas de etiquetado
618 entry: 619 entry:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
index 627923b0..8da90018 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
@@ -613,6 +613,7 @@ flashes:
613 # entries_reset: Entries reset 613 # entries_reset: Entries reset
614 # archived_reset: Archived entries deleted 614 # archived_reset: Archived entries deleted
615 # otp_enabled: Two-factor authentication enabled 615 # otp_enabled: Two-factor authentication enabled
616 # otp_disabled: Two-factor authentication disabled
616 # tagging_rules_imported: Tagging rules imported 617 # tagging_rules_imported: Tagging rules imported
617 # tagging_rules_not_imported: Error while importing tagging rules 618 # tagging_rules_not_imported: Error while importing tagging rules
618 entry: 619 entry:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
index 542dc25c..d5454781 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
@@ -614,6 +614,7 @@ flashes:
614 entries_reset: "Articles supprimés" 614 entries_reset: "Articles supprimés"
615 archived_reset: "Articles archivés supprimés" 615 archived_reset: "Articles archivés supprimés"
616 otp_enabled: "Authentification à double-facteur activée" 616 otp_enabled: "Authentification à double-facteur activée"
617 otp_disabled: "Authentification à double-facteur désactivée"
617 tagging_rules_imported: Règles bien importées 618 tagging_rules_imported: Règles bien importées
618 tagging_rules_not_imported: Impossible d'importer les règles 619 tagging_rules_not_imported: Impossible d'importer les règles
619 entry: 620 entry:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
index 5d017a40..99a8dc2d 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
@@ -613,6 +613,7 @@ flashes:
613 entries_reset: Reset articoli 613 entries_reset: Reset articoli
614 # archived_reset: Archived entries deleted 614 # archived_reset: Archived entries deleted
615 # otp_enabled: Two-factor authentication enabled 615 # otp_enabled: Two-factor authentication enabled
616 # otp_disabled: Two-factor authentication disabled
616 # tagging_rules_imported: Tagging rules imported 617 # tagging_rules_imported: Tagging rules imported
617 # tagging_rules_not_imported: Error while importing tagging rules 618 # tagging_rules_not_imported: Error while importing tagging rules
618 entry: 619 entry:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ja.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ja.yml
index 9de8c571..a1eaa5dd 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.ja.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ja.yml
@@ -613,6 +613,7 @@ flashes:
613 entries_reset: 記事がリセットされました 613 entries_reset: 記事がリセットされました
614 archived_reset: アーカイブ済みの記事がリセットされました 614 archived_reset: アーカイブ済みの記事がリセットされました
615 otp_enabled: 2要素認証が有効化されました 615 otp_enabled: 2要素認証が有効化されました
616 # otp_disabled: Two-factor authentication disabled
616 tagging_rules_imported: タグ付けルールがインポートされました 617 tagging_rules_imported: タグ付けルールがインポートされました
617 tagging_rules_not_imported: タグ付けルールのインポート中にエラーが発生しました 618 tagging_rules_not_imported: タグ付けルールのインポート中にエラーが発生しました
618 entry: 619 entry:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
index e0fb1933..598243db 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
@@ -613,6 +613,7 @@ flashes:
613 entries_reset: Articles levats 613 entries_reset: Articles levats
614 archived_reset: Articles archivat suprimits 614 archived_reset: Articles archivat suprimits
615 otp_enabled: Autentificacion en dos temps activada 615 otp_enabled: Autentificacion en dos temps activada
616 # otp_disabled: Two-factor authentication disabled
616 tagging_rules_imported: Règlas d’etiquetatge importadas 617 tagging_rules_imported: Règlas d’etiquetatge importadas
617 tagging_rules_not_imported: Error en important las règlas d’etiquetatge 618 tagging_rules_not_imported: Error en important las règlas d’etiquetatge
618 entry: 619 entry:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
index dfaf9e89..af8447fe 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
@@ -613,6 +613,7 @@ flashes:
613 entries_reset: Zresetuj wpisy 613 entries_reset: Zresetuj wpisy
614 archived_reset: Zarchiwizowane wpisy usunięte 614 archived_reset: Zarchiwizowane wpisy usunięte
615 # otp_enabled: Two-factor authentication enabled 615 # otp_enabled: Two-factor authentication enabled
616 # otp_disabled: Two-factor authentication disabled
616 # tagging_rules_imported: Tagging rules imported 617 # tagging_rules_imported: Tagging rules imported
617 # tagging_rules_not_imported: Error while importing tagging rules 618 # tagging_rules_not_imported: Error while importing tagging rules
618 entry: 619 entry:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml
index 8908c0cc..d993cb05 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml
@@ -613,6 +613,7 @@ flashes:
613 entries_reset: Artigos reinicializados 613 entries_reset: Artigos reinicializados
614 archived_reset: Artigos arquivados apagados 614 archived_reset: Artigos arquivados apagados
615 otp_enabled: Autenticação de dois fatores ativada 615 otp_enabled: Autenticação de dois fatores ativada
616 # otp_disabled: Two-factor authentication disabled
616 tagging_rules_imported: Regras de tags importadas 617 tagging_rules_imported: Regras de tags importadas
617 tagging_rules_not_imported: Erro ao importar regras de tags 618 tagging_rules_not_imported: Erro ao importar regras de tags
618 entry: 619 entry:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
index b269578a..bc8b72e0 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
@@ -613,6 +613,7 @@ flashes:
613 # entries_reset: Entries reset 613 # entries_reset: Entries reset
614 # archived_reset: Archived entries deleted 614 # archived_reset: Archived entries deleted
615 # otp_enabled: Two-factor authentication enabled 615 # otp_enabled: Two-factor authentication enabled
616 # otp_disabled: Two-factor authentication disabled
616 # tagging_rules_imported: Tagging rules imported 617 # tagging_rules_imported: Tagging rules imported
617 # tagging_rules_not_imported: Error while importing tagging rules 618 # tagging_rules_not_imported: Error while importing tagging rules
618 entry: 619 entry:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml
index 648bbc80..2f7f55e5 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml
@@ -613,6 +613,7 @@ flashes:
613 entries_reset: "Записи сброшены" 613 entries_reset: "Записи сброшены"
614 # archived_reset: Archived entries deleted 614 # archived_reset: Archived entries deleted
615 # otp_enabled: Two-factor authentication enabled 615 # otp_enabled: Two-factor authentication enabled
616 # otp_disabled: Two-factor authentication disabled
616 # tagging_rules_imported: Tagging rules imported 617 # tagging_rules_imported: Tagging rules imported
617 # tagging_rules_not_imported: Error while importing tagging rules 618 # tagging_rules_not_imported: Error while importing tagging rules
618 entry: 619 entry:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml
index 4de87adc..48e1c34a 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml
@@ -613,6 +613,7 @@ flashes:
613 entries_reset: รีเซ็ตรายการ 613 entries_reset: รีเซ็ตรายการ
614 archived_reset: การลบเอกสารของรายการ 614 archived_reset: การลบเอกสารของรายการ
615 # otp_enabled: Two-factor authentication enabled 615 # otp_enabled: Two-factor authentication enabled
616 # otp_disabled: Two-factor authentication disabled
616 # tagging_rules_imported: Tagging rules imported 617 # tagging_rules_imported: Tagging rules imported
617 # tagging_rules_not_imported: Error while importing tagging rules 618 # tagging_rules_not_imported: Error while importing tagging rules
618 entry: 619 entry:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
index 9afa648c..19029c0b 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
@@ -613,6 +613,7 @@ flashes:
613 # entries_reset: Entries reset 613 # entries_reset: Entries reset
614 # archived_reset: Archived entries deleted 614 # archived_reset: Archived entries deleted
615 # otp_enabled: Two-factor authentication enabled 615 # otp_enabled: Two-factor authentication enabled
616 # otp_disabled: Two-factor authentication disabled
616 # tagging_rules_imported: Tagging rules imported 617 # tagging_rules_imported: Tagging rules imported
617 # tagging_rules_not_imported: Error while importing tagging rules 618 # tagging_rules_not_imported: Error while importing tagging rules
618 entry: 619 entry:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.zh.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.zh.yml
index a34e3852..f48ce37a 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.zh.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.zh.yml
@@ -613,6 +613,7 @@ flashes:
613 entries_reset: 项目列表已重置 613 entries_reset: 项目列表已重置
614 archived_reset: 所有存档项目已删除 614 archived_reset: 所有存档项目已删除
615 otp_enabled: 两步验证已启用 615 otp_enabled: 两步验证已启用
616 # otp_disabled: Two-factor authentication disabled
616 tagging_rules_imported: 标签规则已导入 617 tagging_rules_imported: 标签规则已导入
617 tagging_rules_not_imported: 导入标签规则时发生了错误 618 tagging_rules_not_imported: 导入标签规则时发生了错误
618 entry: 619 entry:
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig
index f719bea2..eb395eac 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig
@@ -195,12 +195,12 @@
195 <tr> 195 <tr>
196 <td>{{ 'config.form_user.two_factor.emailTwoFactor_label'|trans }}</td> 196 <td>{{ 'config.form_user.two_factor.emailTwoFactor_label'|trans }}</td>
197 <td>{% if app.user.isEmailTwoFactor %}<b>{{ 'config.form_user.two_factor.state_enabled'|trans }}</b>{% else %}{{ 'config.form_user.two_factor.state_disabled'|trans }}{% endif %}</td> 197 <td>{% if app.user.isEmailTwoFactor %}<b>{{ 'config.form_user.two_factor.state_enabled'|trans }}</b>{% else %}{{ 'config.form_user.two_factor.state_disabled'|trans }}{% endif %}</td>
198 <td><a href="{{ path('config_otp_email') }}" class="waves-effect waves-light btn{% if app.user.isEmailTwoFactor %} disabled{% endif %}">{{ 'config.form_user.two_factor.action_email'|trans }}</a></td> 198 <td><a href="{{ path('config_otp_email') }}" class="waves-effect waves-light btn{% if app.user.isEmailTwoFactor %} disabled{% endif %}">{{ 'config.form_user.two_factor.action_email'|trans }}</a> {% if app.user.isEmailTwoFactor %}<a href="{{ path('disable_otp_email') }}" class="waves-effect waves-light btn">Disable</a>{% endif %}</td>
199 </tr> 199 </tr>
200 <tr> 200 <tr>
201 <td>{{ 'config.form_user.two_factor.googleTwoFactor_label'|trans }}</td> 201 <td>{{ 'config.form_user.two_factor.googleTwoFactor_label'|trans }}</td>
202 <td>{% if app.user.isGoogleTwoFactor %}<b>{{ 'config.form_user.two_factor.state_enabled'|trans }}</b>{% else %}{{ 'config.form_user.two_factor.state_disabled'|trans }}{% endif %}</td> 202 <td>{% if app.user.isGoogleTwoFactor %}<b>{{ 'config.form_user.two_factor.state_enabled'|trans }}</b>{% else %}{{ 'config.form_user.two_factor.state_disabled'|trans }}{% endif %}</td>
203 <td><a href="{{ path('config_otp_app') }}" class="waves-effect waves-light btn{% if app.user.isGoogleTwoFactor %} disabled{% endif %}">{{ 'config.form_user.two_factor.action_app'|trans }}</a></td> 203 <td><a href="{{ path('config_otp_app') }}" class="waves-effect waves-light btn{% if app.user.isGoogleTwoFactor %} disabled{% endif %}">{{ 'config.form_user.two_factor.action_app'|trans }}</a> {% if app.user.isGoogleTwoFactor %}<a href="{{ path('disable_otp_app') }}" class="waves-effect waves-light btn">Disable</a>{% endif %}</td>
204 </tr> 204 </tr>
205 </tbody> 205 </tbody>
206 </table> 206 </table>
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig
index d8e9694d..c2e92ad1 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig
@@ -229,12 +229,12 @@
229 <tr> 229 <tr>
230 <td>{{ 'config.form_user.two_factor.emailTwoFactor_label'|trans }}</td> 230 <td>{{ 'config.form_user.two_factor.emailTwoFactor_label'|trans }}</td>
231 <td>{% if app.user.isEmailTwoFactor %}<b>{{ 'config.form_user.two_factor.state_enabled'|trans }}</b>{% else %}{{ 'config.form_user.two_factor.state_disabled'|trans }}{% endif %}</td> 231 <td>{% if app.user.isEmailTwoFactor %}<b>{{ 'config.form_user.two_factor.state_enabled'|trans }}</b>{% else %}{{ 'config.form_user.two_factor.state_disabled'|trans }}{% endif %}</td>
232 <td><a href="{{ path('config_otp_email') }}" class="waves-effect waves-light btn{% if app.user.isEmailTwoFactor %} disabled{% endif %}">{{ 'config.form_user.two_factor.action_email'|trans }}</a></td> 232 <td><a href="{{ path('config_otp_email') }}" class="waves-effect waves-light btn{% if app.user.isEmailTwoFactor %} disabled{% endif %}">{{ 'config.form_user.two_factor.action_email'|trans }}</a> {% if app.user.isEmailTwoFactor %}<a href="{{ path('disable_otp_email') }}" class="waves-effect waves-light btn red">Disable</a>{% endif %}</td>
233 </tr> 233 </tr>
234 <tr> 234 <tr>
235 <td>{{ 'config.form_user.two_factor.googleTwoFactor_label'|trans }}</td> 235 <td>{{ 'config.form_user.two_factor.googleTwoFactor_label'|trans }}</td>
236 <td>{% if app.user.isGoogleTwoFactor %}<b>{{ 'config.form_user.two_factor.state_enabled'|trans }}</b>{% else %}{{ 'config.form_user.two_factor.state_disabled'|trans }}{% endif %}</td> 236 <td>{% if app.user.isGoogleTwoFactor %}<b>{{ 'config.form_user.two_factor.state_enabled'|trans }}</b>{% else %}{{ 'config.form_user.two_factor.state_disabled'|trans }}{% endif %}</td>
237 <td><a href="{{ path('config_otp_app') }}" class="waves-effect waves-light btn{% if app.user.isGoogleTwoFactor %} disabled{% endif %}">{{ 'config.form_user.two_factor.action_app'|trans }}</a></td> 237 <td><a href="{{ path('config_otp_app') }}" class="waves-effect waves-light btn{% if app.user.isGoogleTwoFactor %} disabled{% endif %}">{{ 'config.form_user.two_factor.action_app'|trans }}</a> {% if app.user.isGoogleTwoFactor %}<a href="{{ path('disable_otp_app') }}" class="waves-effect waves-light btn red">Disable</a>{% endif %}</td>
238 </tr> 238 </tr>
239 </tbody> 239 </tbody>
240 </table> 240 </table>
diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
index fa93c9c2..b3b3a19a 100644
--- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
@@ -1045,6 +1045,29 @@ class ConfigControllerTest extends WallabagCoreTestCase
1045 $em->flush(); 1045 $em->flush();
1046 } 1046 }
1047 1047
1048 public function testUserDisable2faEmail()
1049 {
1050 $this->logInAs('admin');
1051 $client = $this->getClient();
1052
1053 $crawler = $client->request('GET', '/config/otp/email/disable');
1054
1055 $this->assertSame(302, $client->getResponse()->getStatusCode());
1056
1057 $crawler = $client->followRedirect();
1058
1059 $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
1060 $this->assertContains('flashes.config.notice.otp_disabled', $alert[0]);
1061
1062 // restore user
1063 $em = $this->getEntityManager();
1064 $user = $em
1065 ->getRepository('WallabagUserBundle:User')
1066 ->findOneByUsername('admin');
1067
1068 $this->assertFalse($user->isEmailTwoFactor());
1069 }
1070
1048 public function testUserEnable2faGoogle() 1071 public function testUserEnable2faGoogle()
1049 { 1072 {
1050 $this->logInAs('admin'); 1073 $this->logInAs('admin');
@@ -1099,6 +1122,30 @@ class ConfigControllerTest extends WallabagCoreTestCase
1099 $this->assertEmpty($user->getBackupCodes()); 1122 $this->assertEmpty($user->getBackupCodes());
1100 } 1123 }
1101 1124
1125 public function testUserDisable2faGoogle()
1126 {
1127 $this->logInAs('admin');
1128 $client = $this->getClient();
1129
1130 $crawler = $client->request('GET', '/config/otp/app/disable');
1131
1132 $this->assertSame(302, $client->getResponse()->getStatusCode());
1133
1134 $crawler = $client->followRedirect();
1135
1136 $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
1137 $this->assertContains('flashes.config.notice.otp_disabled', $alert[0]);
1138
1139 // restore user
1140 $em = $this->getEntityManager();
1141 $user = $em
1142 ->getRepository('WallabagUserBundle:User')
1143 ->findOneByUsername('admin');
1144
1145 $this->assertEmpty($user->getGoogleAuthenticatorSecret());
1146 $this->assertEmpty($user->getBackupCodes());
1147 }
1148
1102 public function testExportTaggingRule() 1149 public function testExportTaggingRule()
1103 { 1150 {
1104 $this->logInAs('admin'); 1151 $this->logInAs('admin');