Skip to content

EspoCRM – Open Source CRM Application

2FA in portal disabled check

Yurii285b0bd9d7d2
diff --git a/application/Espo/Core/Authentication/Authentication.php b/application/Espo/Core/Authentication/Authentication.php
index 529a9fac6f..620497c099 100644
--- a/application/Espo/Core/Authentication/Authentication.php
+++ b/application/Espo/Core/Authentication/Authentication.php
@@ -237,7 +237,7 @@ class Authentication
!$result->bypassSecondStep() &&
!$result->isSecondStepRequired() &&
!$authToken &&
- $this->configDataProvider->isTwoFactorEnabled()
+ $this->getTwoFactorEnabled()
) {
$result = $this->processTwoFactor($result, $request);
@@ -833,4 +833,13 @@ class Authentication
return $this->processFail($result, $data, $request);
}
+
+ private function getTwoFactorEnabled(): bool
+ {
+ if ($this->isPortal() && !$this->configDataProvider->isTwoFactorInPortalEnabled()) {
+ return false;
+ }
+
+ return $this->configDataProvider->isTwoFactorEnabled();
+ }
}
diff --git a/application/Espo/Core/Authentication/ConfigDataProvider.php b/application/Espo/Core/Authentication/ConfigDataProvider.php
index d38960a817..ec17647d1a 100644
--- a/application/Espo/Core/Authentication/ConfigDataProvider.php
+++ b/application/Espo/Core/Authentication/ConfigDataProvider.php
@@ -117,6 +117,16 @@ class ConfigDataProvider
return (bool) $this->config->get('auth2FA');
}
+ /**
+ * Whether 2FA is enabled in portals.
+ *
+ * @since 10.0.4
+ */
+ public function isTwoFactorInPortalEnabled(): bool
+ {
+ return (bool) $this->config->get('auth2FAInPortal');
+ }
+
/**
* Allowed methods of 2FA.
*