From 2019d32b3d62d12b460018c5d1f5f3e171b104b9 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 18 Apr 2011 10:46:40 -0400 Subject: [PATCH] let other validity checks go through first --- .../DomainWhitelist/DomainWhitelistPlugin.php | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/plugins/DomainWhitelist/DomainWhitelistPlugin.php b/plugins/DomainWhitelist/DomainWhitelistPlugin.php index 615701f36b..c20e3f02c0 100644 --- a/plugins/DomainWhitelist/DomainWhitelistPlugin.php +++ b/plugins/DomainWhitelist/DomainWhitelistPlugin.php @@ -52,18 +52,20 @@ class DomainWhitelistPlugin extends Plugin return true; } - function onStartValidateUserEmail($user, $email, &$valid) + function onEndValidateUserEmail($user, $email, &$valid) { - if (!$this->matchesWhitelist($email)) { - $whitelist = $this->getWhitelist(); - if (count($whitelist) == 1) { - $message = sprintf(_("Email address must be in this domain: %s"), - $whitelist[0]); - } else { - $message = sprintf(_("Email address must be in one of these domains: %s"), - implode(', ', $whitelist)); + if ($valid) { // it's otherwise valid + if (!$this->matchesWhitelist($email)) { + $whitelist = $this->getWhitelist(); + if (count($whitelist) == 1) { + $message = sprintf(_("Email address must be in this domain: %s"), + $whitelist[0]); + } else { + $message = sprintf(_("Email address must be in one of these domains: %s"), + implode(', ', $whitelist)); + } + throw new ClientException($message); } - throw new ClientException($message); } return true; } -- 2.39.5