Allow admins to disable the 2FA for a standard user

This commit is contained in:
Frederic Guillot 2015-04-21 19:53:33 -04:00
parent e30bf47d94
commit 71112eb81d
21 changed files with 80 additions and 0 deletions

View File

@ -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,
)));
}
}

View File

@ -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"?' => '',
);

View File

@ -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"?' => '',
);

View File

@ -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"?' => '',
);

View File

@ -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"?' => '',
);

View File

@ -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 » ?',
);

View File

@ -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"?' => '',
);

View File

@ -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"?' => '',
);

View File

@ -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"?' => '',
);

View File

@ -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"?' => '',
);

View File

@ -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"?' => '',
);

View File

@ -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"?' => '',
);

View File

@ -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"?' => '',
);

View File

@ -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"?' => '',
);

View File

@ -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"?' => '',
);

View File

@ -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"?' => '',
);

View File

@ -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"?' => '',
);

View File

@ -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"?' => '',
);

View File

@ -74,6 +74,7 @@ class Acl extends Base
'project' => array('remove'),
'hourlyrate' => '*',
'currency' => '*',
'twofactor' => array('disable'),
);
/**

View File

@ -0,0 +1,14 @@
<div class="page-header">
<h2><?= t('Disable two factor authentication') ?></h2>
</div>
<div class="confirm">
<p class="alert alert-info">
<?= t('Do you really want to disable the two factor authentication for this user: "%s"?', $user['name'] ?: $user['username']) ?>
</p>
<div class="form-actions">
<?= $this->a(t('Yes'), 'twofactor', 'disable', array('user_id' => $user['id'], 'disable' => 'yes'), true, 'btn btn-red') ?>
<?= t('or') ?> <?= $this->a(t('cancel'), 'user', 'show', array('user_id' => $user['id'])) ?>
</div>
</div>

View File

@ -42,6 +42,10 @@
<li>
<?= $this->a(t('Two factor authentication'), 'twofactor', 'index', array('user_id' => $user['id'])) ?>
</li>
<?php elseif ($this->userSession->isAdmin() && $user['twofactor_activated'] == 1): ?>
<li>
<?= $this->a(t('Two factor authentication'), 'twofactor', 'disable', array('user_id' => $user['id'])) ?>
</li>
<?php endif ?>
<li>