From 89e5fd5129a778123ef151e1ce452ba75a2ab910 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Tue, 2 Apr 2019 17:46:48 +0000 Subject: [PATCH] authsympa : Add namespace support git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5190 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- authsympa.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/authsympa.php b/authsympa.php index d227695..08453c6 100644 --- a/authsympa.php +++ b/authsympa.php @@ -4,6 +4,7 @@ @author Dominique Fournier */ require_once ("domframework/auth.php"); + /** User authentication against SYMPA server Sympa is a mailling list server. It can handle authentication with - a username (a email adress) @@ -41,7 +42,7 @@ class authsympa extends auth public function __construct () { if (! class_exists ("SoapClient")) - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext("domframework", "No SOAP PHP library available"), 500); } @@ -49,9 +50,9 @@ class authsympa extends auth public function connect () { if ($this->wsdl === null) - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext("domframework", "No WSDL provided to Sympa auth"), 401); - $this->client = new SoapClient($this->wsdl); + $this->client = new \SoapClient($this->wsdl); } /** Try to authenticate the email/password of the user @@ -60,20 +61,21 @@ class authsympa extends auth public function authentication ($email, $password) { if ($this->client === null) - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext("domframework", "The SOAP connection is not opened"), 401); if ($this->list === null) - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext("domframework", "The list to check is not defined"), 401); $this->authkey = $this->client->login ($email, $password); if ($this->authkey === null) - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext("domframework", "Can't connect with provided email/password to sympa"), 401); $rc = $this->client->authenticateAndRun ($email, $this->authkey, 'amI', array ($this->list, $this->function, $email)); - if ($rc === null) - return FALSE; + if ($rc === null || $rc === false) + throw new \Exception (dgettext("domframework", + "User not in Sympa list or bad password"), 401); $this->details = array ("email"=>$email); return $rc; } @@ -90,7 +92,7 @@ class authsympa extends auth @param string $newpassword The new password to be recorded */ public function changepassword ($oldpassword, $newpassword) { - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext("domframework", "The password can't be change for SYMPA users"), 405); } @@ -102,7 +104,7 @@ class authsympa extends auth @param string $newpassword The new password to be recorded */ public function overwritepassword ($email, $newpassword) { - throw new exception (dgettext("domframework", + throw new \Exception (dgettext("domframework", "The password can't be overwrite for Sympa users"), 405); }