Improve 2FA
This commit is contained in:
@@ -207,10 +207,9 @@ abstract class Base
|
|||||||
*/
|
*/
|
||||||
public function handle2FA($controller, $action)
|
public function handle2FA($controller, $action)
|
||||||
{
|
{
|
||||||
$controllers = array('twofactor', 'user');
|
$ignore = ($controller === 'twofactor' && in_array($action, array('code', 'check'))) || ($controller === 'user' && $action === 'logout');
|
||||||
$actions = array('code', 'check', 'logout');
|
|
||||||
|
|
||||||
if ($this->userSession->has2FA() && ! $this->userSession->check2FA() && ! in_array($controller, $controllers) && ! in_array($action, $actions)) {
|
if ($ignore === false && $this->userSession->has2FA() && ! $this->userSession->check2FA()) {
|
||||||
|
|
||||||
if ($this->request->isAjax()) {
|
if ($this->request->isAjax()) {
|
||||||
$this->response->text('Not Authorized', 401);
|
$this->response->text('Not Authorized', 401);
|
||||||
|
|||||||
@@ -72,6 +72,9 @@ class Twofactor extends User
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Allow the user to test or disable the feature
|
||||||
|
$this->session['user']['twofactor_activated'] = false;
|
||||||
|
|
||||||
$this->session->flash(t('User updated successfully.'));
|
$this->session->flash(t('User updated successfully.'));
|
||||||
$this->response->redirect($this->helper->url('twofactor', 'index', array('user_id' => $user['id'])));
|
$this->response->redirect($this->helper->url('twofactor', 'index', array('user_id' => $user['id'])));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user