From 6f9e82953d2aac6ba3d2618c77ada4859dd490bd Mon Sep 17 00:00:00 2001 From: f-elix Date: Wed, 24 Jul 2024 16:43:19 -0400 Subject: [PATCH] Only prevent password login from the login page --- src/Plugin.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Plugin.php b/src/Plugin.php index 04a219a..f879384 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -71,7 +71,7 @@ public function onAfterPluginLoad($event) $isLoginPage = \Craft::$app->getRequest()->getSegment(1) === 'login'; // only register css and js if we are on the login page - if (!$isConsoleRequest && (bool) $isCPRequest && (bool) $isLoginPage) { + if ((bool) $isCPRequest && (bool) $isLoginPage) { \Craft::$app->getView()->registerAssetBundle(LoginAsset::class); } } @@ -84,6 +84,8 @@ public function onBeforeLogin($event) $client_id = isset($config['client_id']) ? $config['client_id'] : null; $client_secret = isset($config['client_secret']) ? $config['client_secret'] : null; + $isLoginPage = \Craft::$app->getRequest()->getSegment(1) === 'login'; + // only block the user if the email is from sso domain AND the client_id/secret is not set if ( !empty($domain) @@ -93,7 +95,7 @@ public function onBeforeLogin($event) ) { $request = \Craft::$app->getRequest(); $body = $request->getBodyParams(); - if (isset($body['password'])) { + if (isset($body['password']) && $isLoginPage) { throw new \Exception('Agency users can\'t login with their password. Please use your Google Workspace account.'); } }