Skip to content

Commit

Permalink
adjust how it checks user values
Browse files Browse the repository at this point in the history
  • Loading branch information
matdave committed Dec 28, 2022
1 parent ce7a4aa commit 0f4b20c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions core/components/twilio/src/Event/OnBeforeManagerPageInit.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ public function run()
{
// System Wide
$enforceTotp = $this->getOption('twilio.totp_enforce', false);
// User Specific
$userTotp = $this->getOption('twilio.totp', false);
$action = $this->getOption('action');
$user = $this->modx->user;
if (!$user || $user->id === 0) {
return false;
}
// User Specific
$userTotp = $user->getOption('twilio.totp', $user->getSettings(), false);
if ($enforceTotp && $userTotp && !$_SESSION['twilio_totp_verified'] && $action !== 'totp') {
$this->modx->sendRedirect(MODX_MANAGER_URL . 'index.php?a=totp&namespace=twilio');
}
Expand Down
4 changes: 2 additions & 2 deletions core/components/twilio/src/Event/OnManagerPageInit.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ public function run()
{
// System Wide
$enforceTotp = $this->getOption('twilio.totp_enforce', false);
// User Specific
$userTotp = $this->getOption('twilio.totp', false);
$action = $this->getOption('action');
$user = $this->modx->user;
if (!$user || $user->id === 0) {
return false;
}
// User Specific
$userTotp = $user->getOption('twilio.totp', $user->getSettings(), false);
if (($enforceTotp || $userTotp) && $action === 'security/profile') {
$this->modx->regClientStartupScript($this->twilio->getOption('jsUrl') . 'mgr/twilio.js');
$profile = $user->getOne('Profile');
Expand Down
4 changes: 2 additions & 2 deletions core/components/twilio/src/Event/OnWebPagePrerender.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ public function run()
{
// System Wide
$enforceTotp = $this->getOption('twilio.totp_enforce', false);
// User Specific
$userTotp = $this->getOption('twilio.totp', false);
$totpChallenge = (int) $this->getOption('twilio.totp_challenge_page', 0);
$user = $this->modx->user;
if (!$user || $user->id === 0 || $this->modx->resource->id === $totpChallenge) {
return;
}
// User Specific
$userTotp = $user->getOption('twilio.totp', $user->getSettings(), false);
if ($enforceTotp && $userTotp && !$_SESSION['twilio_totp_verified'] && $totpChallenge > 0) {
if ($this->modx->getOption('twilio.totp_email_on_login', null, false)) {
$this->sendEmail($user);
Expand Down

0 comments on commit 0f4b20c

Please sign in to comment.