Skip to content

Commit ce7a4aa

Browse files
committed
Check if user has TOTP enabled
1 parent f24252b commit ce7a4aa

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

_build/gpm.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"lowCaseName": "twilio",
44
"description": "Twilio for MODX Revolution 3.x",
55
"author": "John Peca",
6-
"version": "2.0.0",
6+
"version": "2.0.1",
77
"menus": [
88
{
99
"text": "twilio.users",

core/components/twilio/src/Event/OnBeforeManagerPageInit.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ class OnBeforeManagerPageInit extends Event
88
{
99
public function run()
1010
{
11+
// System Wide
1112
$enforceTotp = $this->getOption('twilio.totp_enforce', false);
13+
// User Specific
14+
$userTotp = $this->getOption('twilio.totp', false);
1215
$action = $this->getOption('action');
1316
$user = $this->modx->user;
1417
if (!$user || $user->id === 0) {
1518
return false;
1619
}
17-
if ($enforceTotp && !$_SESSION['twilio_totp_verified'] && $action !== 'totp') {
20+
if ($enforceTotp && $userTotp && !$_SESSION['twilio_totp_verified'] && $action !== 'totp') {
1821
$this->modx->sendRedirect(MODX_MANAGER_URL . 'index.php?a=totp&namespace=twilio');
1922
}
2023
}

core/components/twilio/src/Event/OnManagerPageInit.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ class OnManagerPageInit extends Event
66
{
77
public function run()
88
{
9+
// System Wide
910
$enforceTotp = $this->getOption('twilio.totp_enforce', false);
11+
// User Specific
12+
$userTotp = $this->getOption('twilio.totp', false);
1013
$action = $this->getOption('action');
1114
$user = $this->modx->user;
1215
if (!$user || $user->id === 0) {
1316
return false;
1417
}
15-
if ($enforceTotp && $action === 'security/profile') {
18+
if (($enforceTotp || $userTotp) && $action === 'security/profile') {
1619
$this->modx->regClientStartupScript($this->twilio->getOption('jsUrl') . 'mgr/twilio.js');
1720
$profile = $user->getOne('Profile');
1821
$extended = $profile->get('extended');

core/components/twilio/src/Event/OnWebPagePrerender.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ class OnWebPagePrerender extends Event
66
{
77
public function run()
88
{
9+
// System Wide
910
$enforceTotp = $this->getOption('twilio.totp_enforce', false);
11+
// User Specific
12+
$userTotp = $this->getOption('twilio.totp', false);
1013
$totpChallenge = (int) $this->getOption('twilio.totp_challenge_page', 0);
1114
$user = $this->modx->user;
1215
if (!$user || $user->id === 0 || $this->modx->resource->id === $totpChallenge) {
1316
return;
1417
}
15-
if ($enforceTotp && !$_SESSION['twilio_totp_verified'] && $totpChallenge > 0) {
18+
if ($enforceTotp && $userTotp && !$_SESSION['twilio_totp_verified'] && $totpChallenge > 0) {
1619
if ($this->modx->getOption('twilio.totp_email_on_login', null, false)) {
1720
$this->sendEmail($user);
1821
}

0 commit comments

Comments
 (0)