From 71112eb81d28b7baee09bf7d73e80a81cb38c17a Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Tue, 21 Apr 2015 19:53:33 -0400 Subject: [PATCH] Allow admins to disable the 2FA for a standard user --- app/Controller/Twofactor.php | 27 ++++++++++++++++++++++++++ app/Locale/da_DK/translations.php | 2 ++ app/Locale/de_DE/translations.php | 2 ++ app/Locale/es_ES/translations.php | 2 ++ app/Locale/fi_FI/translations.php | 2 ++ app/Locale/fr_FR/translations.php | 2 ++ app/Locale/hu_HU/translations.php | 2 ++ app/Locale/it_IT/translations.php | 2 ++ app/Locale/ja_JP/translations.php | 2 ++ app/Locale/nl_NL/translations.php | 2 ++ app/Locale/pl_PL/translations.php | 2 ++ app/Locale/pt_BR/translations.php | 2 ++ app/Locale/ru_RU/translations.php | 2 ++ app/Locale/sr_Latn_RS/translations.php | 2 ++ app/Locale/sv_SE/translations.php | 2 ++ app/Locale/th_TH/translations.php | 2 ++ app/Locale/tr_TR/translations.php | 2 ++ app/Locale/zh_CN/translations.php | 2 ++ app/Model/Acl.php | 1 + app/Template/twofactor/disable.php | 14 +++++++++++++ app/Template/user/sidebar.php | 4 ++++ 21 files changed, 80 insertions(+) create mode 100644 app/Template/twofactor/disable.php diff --git a/app/Controller/Twofactor.php b/app/Controller/Twofactor.php index e3451d337..c21729bae 100644 --- a/app/Controller/Twofactor.php +++ b/app/Controller/Twofactor.php @@ -137,4 +137,31 @@ class Twofactor extends User 'title' => t('Check two factor authentication code'), ))); } + + /** + * Disable 2FA for a user + * + * @access public + */ + public function disable() + { + $user = $this->getUser(); + + if ($this->request->getStringParam('disable') === 'yes') { + + $this->checkCSRFParam(); + + $this->user->update(array( + 'id' => $user['id'], + 'twofactor_activated' => 0, + 'twofactor_secret' => '', + )); + + $this->response->redirect($this->helper->url('user', 'show', array('user_id' => $user['id']))); + } + + $this->response->html($this->layout('twofactor/disable', array( + 'user' => $user, + ))); + } } diff --git a/app/Locale/da_DK/translations.php b/app/Locale/da_DK/translations.php index f1352b8d6..f06f87c14 100644 --- a/app/Locale/da_DK/translations.php +++ b/app/Locale/da_DK/translations.php @@ -866,4 +866,6 @@ return array( // 'Help on Mailgun integration' => '', // 'Sendgrid (incoming emails)' => '', // 'Help on Sendgrid integration' => '', + // 'Disable two factor authentication' => '', + // 'Do you really want to disable the two factor authentication for this user: "%s"?' => '', ); diff --git a/app/Locale/de_DE/translations.php b/app/Locale/de_DE/translations.php index 2fc01f3e6..1d43cf0cd 100644 --- a/app/Locale/de_DE/translations.php +++ b/app/Locale/de_DE/translations.php @@ -866,4 +866,6 @@ return array( // 'Help on Mailgun integration' => '', // 'Sendgrid (incoming emails)' => '', // 'Help on Sendgrid integration' => '', + // 'Disable two factor authentication' => '', + // 'Do you really want to disable the two factor authentication for this user: "%s"?' => '', ); diff --git a/app/Locale/es_ES/translations.php b/app/Locale/es_ES/translations.php index c150bfe50..cd636f780 100644 --- a/app/Locale/es_ES/translations.php +++ b/app/Locale/es_ES/translations.php @@ -866,4 +866,6 @@ return array( // 'Help on Mailgun integration' => '', // 'Sendgrid (incoming emails)' => '', // 'Help on Sendgrid integration' => '', + // 'Disable two factor authentication' => '', + // 'Do you really want to disable the two factor authentication for this user: "%s"?' => '', ); diff --git a/app/Locale/fi_FI/translations.php b/app/Locale/fi_FI/translations.php index 99ead93c6..9ca386d6b 100644 --- a/app/Locale/fi_FI/translations.php +++ b/app/Locale/fi_FI/translations.php @@ -866,4 +866,6 @@ return array( // 'Help on Mailgun integration' => '', // 'Sendgrid (incoming emails)' => '', // 'Help on Sendgrid integration' => '', + // 'Disable two factor authentication' => '', + // 'Do you really want to disable the two factor authentication for this user: "%s"?' => '', ); diff --git a/app/Locale/fr_FR/translations.php b/app/Locale/fr_FR/translations.php index 709131a6c..c05dd689d 100644 --- a/app/Locale/fr_FR/translations.php +++ b/app/Locale/fr_FR/translations.php @@ -868,4 +868,6 @@ return array( 'Help on Mailgun integration' => 'Aide sur l\'intégration avec Mailgun', 'Sendgrid (incoming emails)' => 'Sendgrid (emails entrants)', 'Help on Sendgrid integration' => 'Aide sur l\'intégration avec Sendgrid', + 'Disable two factor authentication' => 'Désactiver l\'authentification à deux facteurs', + 'Do you really want to disable the two factor authentication for this user: "%s"?' => 'Voulez-vous vraiment désactiver l\'authentification à deux facteurs pour cet utilisateur : « %s » ?', ); diff --git a/app/Locale/hu_HU/translations.php b/app/Locale/hu_HU/translations.php index d2d0d6e9c..f07b691c2 100644 --- a/app/Locale/hu_HU/translations.php +++ b/app/Locale/hu_HU/translations.php @@ -866,4 +866,6 @@ return array( // 'Help on Mailgun integration' => '', // 'Sendgrid (incoming emails)' => '', // 'Help on Sendgrid integration' => '', + // 'Disable two factor authentication' => '', + // 'Do you really want to disable the two factor authentication for this user: "%s"?' => '', ); diff --git a/app/Locale/it_IT/translations.php b/app/Locale/it_IT/translations.php index c2882ffc8..0ccefe552 100644 --- a/app/Locale/it_IT/translations.php +++ b/app/Locale/it_IT/translations.php @@ -866,4 +866,6 @@ return array( // 'Help on Mailgun integration' => '', // 'Sendgrid (incoming emails)' => '', // 'Help on Sendgrid integration' => '', + // 'Disable two factor authentication' => '', + // 'Do you really want to disable the two factor authentication for this user: "%s"?' => '', ); diff --git a/app/Locale/ja_JP/translations.php b/app/Locale/ja_JP/translations.php index a35ff2e91..644dcfa76 100644 --- a/app/Locale/ja_JP/translations.php +++ b/app/Locale/ja_JP/translations.php @@ -866,4 +866,6 @@ return array( // 'Help on Mailgun integration' => '', // 'Sendgrid (incoming emails)' => '', // 'Help on Sendgrid integration' => '', + // 'Disable two factor authentication' => '', + // 'Do you really want to disable the two factor authentication for this user: "%s"?' => '', ); diff --git a/app/Locale/nl_NL/translations.php b/app/Locale/nl_NL/translations.php index 06a7026af..e0285fdd5 100644 --- a/app/Locale/nl_NL/translations.php +++ b/app/Locale/nl_NL/translations.php @@ -866,4 +866,6 @@ return array( // 'Help on Mailgun integration' => '', // 'Sendgrid (incoming emails)' => '', // 'Help on Sendgrid integration' => '', + // 'Disable two factor authentication' => '', + // 'Do you really want to disable the two factor authentication for this user: "%s"?' => '', ); diff --git a/app/Locale/pl_PL/translations.php b/app/Locale/pl_PL/translations.php index c91d4ba12..39c92379e 100644 --- a/app/Locale/pl_PL/translations.php +++ b/app/Locale/pl_PL/translations.php @@ -866,4 +866,6 @@ return array( // 'Help on Mailgun integration' => '', // 'Sendgrid (incoming emails)' => '', // 'Help on Sendgrid integration' => '', + // 'Disable two factor authentication' => '', + // 'Do you really want to disable the two factor authentication for this user: "%s"?' => '', ); diff --git a/app/Locale/pt_BR/translations.php b/app/Locale/pt_BR/translations.php index 1e5dae59d..223850fc3 100644 --- a/app/Locale/pt_BR/translations.php +++ b/app/Locale/pt_BR/translations.php @@ -866,4 +866,6 @@ return array( // 'Help on Mailgun integration' => '', // 'Sendgrid (incoming emails)' => '', // 'Help on Sendgrid integration' => '', + // 'Disable two factor authentication' => '', + // 'Do you really want to disable the two factor authentication for this user: "%s"?' => '', ); diff --git a/app/Locale/ru_RU/translations.php b/app/Locale/ru_RU/translations.php index 53616d9a4..6f350a824 100644 --- a/app/Locale/ru_RU/translations.php +++ b/app/Locale/ru_RU/translations.php @@ -866,4 +866,6 @@ return array( // 'Help on Mailgun integration' => '', // 'Sendgrid (incoming emails)' => '', // 'Help on Sendgrid integration' => '', + // 'Disable two factor authentication' => '', + // 'Do you really want to disable the two factor authentication for this user: "%s"?' => '', ); diff --git a/app/Locale/sr_Latn_RS/translations.php b/app/Locale/sr_Latn_RS/translations.php index fd5c4f5d0..7dcb6f990 100644 --- a/app/Locale/sr_Latn_RS/translations.php +++ b/app/Locale/sr_Latn_RS/translations.php @@ -866,4 +866,6 @@ return array( // 'Help on Mailgun integration' => '', // 'Sendgrid (incoming emails)' => '', // 'Help on Sendgrid integration' => '', + // 'Disable two factor authentication' => '', + // 'Do you really want to disable the two factor authentication for this user: "%s"?' => '', ); diff --git a/app/Locale/sv_SE/translations.php b/app/Locale/sv_SE/translations.php index 7f765815b..f3d586965 100644 --- a/app/Locale/sv_SE/translations.php +++ b/app/Locale/sv_SE/translations.php @@ -866,4 +866,6 @@ return array( // 'Help on Mailgun integration' => '', // 'Sendgrid (incoming emails)' => '', // 'Help on Sendgrid integration' => '', + // 'Disable two factor authentication' => '', + // 'Do you really want to disable the two factor authentication for this user: "%s"?' => '', ); diff --git a/app/Locale/th_TH/translations.php b/app/Locale/th_TH/translations.php index f282beee7..552e2f430 100644 --- a/app/Locale/th_TH/translations.php +++ b/app/Locale/th_TH/translations.php @@ -866,4 +866,6 @@ return array( // 'Help on Mailgun integration' => '', // 'Sendgrid (incoming emails)' => '', // 'Help on Sendgrid integration' => '', + // 'Disable two factor authentication' => '', + // 'Do you really want to disable the two factor authentication for this user: "%s"?' => '', ); diff --git a/app/Locale/tr_TR/translations.php b/app/Locale/tr_TR/translations.php index 11cba8334..e4efe2583 100644 --- a/app/Locale/tr_TR/translations.php +++ b/app/Locale/tr_TR/translations.php @@ -866,4 +866,6 @@ return array( // 'Help on Mailgun integration' => '', // 'Sendgrid (incoming emails)' => '', // 'Help on Sendgrid integration' => '', + // 'Disable two factor authentication' => '', + // 'Do you really want to disable the two factor authentication for this user: "%s"?' => '', ); diff --git a/app/Locale/zh_CN/translations.php b/app/Locale/zh_CN/translations.php index 09df6d454..a51a54d37 100644 --- a/app/Locale/zh_CN/translations.php +++ b/app/Locale/zh_CN/translations.php @@ -866,4 +866,6 @@ return array( // 'Help on Mailgun integration' => '', // 'Sendgrid (incoming emails)' => '', // 'Help on Sendgrid integration' => '', + // 'Disable two factor authentication' => '', + // 'Do you really want to disable the two factor authentication for this user: "%s"?' => '', ); diff --git a/app/Model/Acl.php b/app/Model/Acl.php index d0e7352ac..d7b96b069 100644 --- a/app/Model/Acl.php +++ b/app/Model/Acl.php @@ -74,6 +74,7 @@ class Acl extends Base 'project' => array('remove'), 'hourlyrate' => '*', 'currency' => '*', + 'twofactor' => array('disable'), ); /** diff --git a/app/Template/twofactor/disable.php b/app/Template/twofactor/disable.php new file mode 100644 index 000000000..6909b4468 --- /dev/null +++ b/app/Template/twofactor/disable.php @@ -0,0 +1,14 @@ + + +
+

+ +

+ +
+ a(t('Yes'), 'twofactor', 'disable', array('user_id' => $user['id'], 'disable' => 'yes'), true, 'btn btn-red') ?> + a(t('cancel'), 'user', 'show', array('user_id' => $user['id'])) ?> +
+
\ No newline at end of file diff --git a/app/Template/user/sidebar.php b/app/Template/user/sidebar.php index f794c609a..ff0fb0092 100644 --- a/app/Template/user/sidebar.php +++ b/app/Template/user/sidebar.php @@ -42,6 +42,10 @@
  • a(t('Two factor authentication'), 'twofactor', 'index', array('user_id' => $user['id'])) ?>
  • + userSession->isAdmin() && $user['twofactor_activated'] == 1): ?> +
  • + a(t('Two factor authentication'), 'twofactor', 'disable', array('user_id' => $user['id'])) ?> +