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