Skip to content

Commit 2d4d7e5

Browse files
committed
Check if user has TOTP enabled
1 parent 00df510 commit 2d4d7e5

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ ehthumbs.db
2727
Thumbs.db
2828
/.php-cs-fixer.cache
2929
deploy*.sh
30+
vendor

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ class OnBeforeManagerPageInit 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 && !$_SESSION['twilio_totp_verified'] && $action['controller'] !== 'totp') {
18+
if ($enforceTotp && $userTotp && !$_SESSION['twilio_totp_verified'] && $action['controller'] !== 'totp') {
1619
$this->modx->sendRedirect(MODX_MANAGER_URL . 'index.php?a=totp&namespace=twilio');
1720
}
1821
}

core/components/twilio/model/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/model/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)