From 7d485813e523bdf5750035f82dd3a0e644acdaf0 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Mon, 4 Mar 2024 10:12:59 +0100 Subject: [PATCH] By default throw AccountNotAllowed as confused in #1478 --- plugins/black-list/index.php | 26 +++++++++++--------------- plugins/white-list/index.php | 26 +++++++++++--------------- 2 files changed, 22 insertions(+), 30 deletions(-) diff --git a/plugins/black-list/index.php b/plugins/black-list/index.php index 7f692f0e4..dea7e90ed 100644 --- a/plugins/black-list/index.php +++ b/plugins/black-list/index.php @@ -4,35 +4,31 @@ class BlackListPlugin extends \RainLoop\Plugins\AbstractPlugin { const NAME = 'Blacklist', - VERSION = '2.1', - RELEASE = '2021-04-21', + VERSION = '2.2', + RELEASE = '2024-03-04', REQUIRED = '2.5.0', CATEGORY = 'Login', DESCRIPTION = 'Simple blacklist extension (with wildcard and exceptions functionality).'; public function Init() : void { - $this->addHook('login.credentials', 'FilterLoginCredentials'); + $this->addHook('login.credentials.step-1', 'FilterLoginCredentials'); } /** - * @param string $sEmail - * @param string $sLogin - * @param string $sPassword - * * @throws \RainLoop\Exceptions\ClientException */ - public function FilterLoginCredentials(&$sEmail, &$sLogin, &$sPassword) + public function FilterLoginCredentials(string &$sEmail) { $sBlackList = \trim($this->Config()->Get('plugin', 'black_list', '')); - if (0 < \strlen($sBlackList) && \RainLoop\Plugins\Helper::ValidateWildcardValues($sEmail, $sBlackList)) - { + if (\strlen($sBlackList) && \RainLoop\Plugins\Helper::ValidateWildcardValues($sEmail, $sBlackList)) { $sExceptions = \trim($this->Config()->Get('plugin', 'exceptions', '')); - if (0 === \strlen($sExceptions) || !\RainLoop\Plugins\Helper::ValidateWildcardValues($sEmail, $sExceptions)) - { + if (!\strlen($sExceptions) || !\RainLoop\Plugins\Helper::ValidateWildcardValues($sEmail, $sExceptions)) { throw new \RainLoop\Exceptions\ClientException( - $this->Config()->Get('plugin', 'auth_error', true) ? - \RainLoop\Notifications::AuthError : \RainLoop\Notifications::AccountNotAllowed); + $this->Config()->Get('plugin', 'auth_error', false) + ? \RainLoop\Notifications::AuthError + : \RainLoop\Notifications::AccountNotAllowed + ); } } } @@ -46,7 +42,7 @@ class BlackListPlugin extends \RainLoop\Plugins\AbstractPlugin \RainLoop\Plugins\Property::NewInstance('auth_error')->SetLabel('Auth Error') ->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL) ->SetDescription('Throw an authentication error instead of an access error.') - ->SetDefaultValue(true), + ->SetDefaultValue(false), \RainLoop\Plugins\Property::NewInstance('black_list')->SetLabel('Black List') ->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING_TEXT) ->SetDescription('Emails black list, space as delimiter, wildcard supported.') diff --git a/plugins/white-list/index.php b/plugins/white-list/index.php index efad99ea8..2b91b8bcc 100644 --- a/plugins/white-list/index.php +++ b/plugins/white-list/index.php @@ -4,35 +4,31 @@ class WhiteListPlugin extends \RainLoop\Plugins\AbstractPlugin { const NAME = 'Whitelist', - VERSION = '2.1', - RELEASE = '2021-04-21', + VERSION = '2.2', + RELEASE = '2024-03-04', REQUIRED = '2.5.0', CATEGORY = 'Login', DESCRIPTION = 'Simple login whitelist (with wildcard and exceptions functionality).'; public function Init() : void { - $this->addHook('login.credentials', 'FilterLoginCredentials'); + $this->addHook('login.credentials.step-1', 'FilterLoginCredentials'); } /** - * @param string $sEmail - * @param string $sLogin - * @param string $sPassword - * * @throws \RainLoop\Exceptions\ClientException */ - public function FilterLoginCredentials(&$sEmail, &$sLogin, &$sPassword) + public function FilterLoginCredentials(string &$sEmail) { $sWhiteList = \trim($this->Config()->Get('plugin', 'white_list', '')); - if (0 < strlen($sWhiteList) && !\RainLoop\Plugins\Helper::ValidateWildcardValues($sEmail, $sWhiteList)) - { + if (\strlen($sWhiteList) && !\RainLoop\Plugins\Helper::ValidateWildcardValues($sEmail, $sWhiteList)) { $sExceptions = \trim($this->Config()->Get('plugin', 'exceptions', '')); - if (0 === \strlen($sExceptions) || !\RainLoop\Plugins\Helper::ValidateWildcardValues($sEmail, $sExceptions)) - { + if (!\strlen($sExceptions) || \RainLoop\Plugins\Helper::ValidateWildcardValues($sEmail, $sExceptions)) { throw new \RainLoop\Exceptions\ClientException( - $this->Config()->Get('plugin', 'auth_error', true) ? - \RainLoop\Notifications::AuthError : \RainLoop\Notifications::AccountNotAllowed); + $this->Config()->Get('plugin', 'auth_error', false) + ? \RainLoop\Notifications::AuthError + : \RainLoop\Notifications::AccountNotAllowed + ); } } } @@ -46,7 +42,7 @@ class WhiteListPlugin extends \RainLoop\Plugins\AbstractPlugin \RainLoop\Plugins\Property::NewInstance('auth_error')->SetLabel('Auth Error') ->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL) ->SetDescription('Throw an authentication error instead of an access error.') - ->SetDefaultValue(true), + ->SetDefaultValue(false), \RainLoop\Plugins\Property::NewInstance('white_list')->SetLabel('White List') ->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING_TEXT) ->SetDescription('Emails white list, space as delimiter, wildcard supported.')