From 71112eb81d28b7baee09bf7d73e80a81cb38c17a Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Tue, 21 Apr 2015 19:53:33 -0400 Subject: 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 (limited to 'app') diff --git a/app/Controller/Twofactor.php b/app/Controller/Twofactor.php index e3451d33..c21729ba 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 f1352b8d..f06f87c1 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 2fc01f3e..1d43cf0c 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 c150bfe5..cd636f78 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 99ead93c..9ca386d6 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 709131a6..c05dd689 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 d2d0d6e9..f07b691c 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 c2882ffc..0ccefe55 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 a35ff2e9..644dcfa7 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 06a7026a..e0285fdd 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 c91d4ba1..39c92379 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 1e5dae59..223850fc 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 53616d9a..6f350a82 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 fd5c4f5d..7dcb6f99 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 7f765815..f3d58696 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 f282beee..552e2f43 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 11cba833..e4efe258 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 09df6d45..a51a54d3 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 d0e7352a..d7b96b06 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 00000000..6909b446 --- /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 f794c609..ff0fb009 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'])) ?> +
  • -- cgit v1.2.3