From a877f06fe9ad5220bc9fda86eba582d4055a55b0 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Tue, 16 Sep 2014 11:41:01 +0000 Subject: [PATCH] authsession : add the capability to store the informations in session git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1822 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- authsession.php | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/authsession.php b/authsession.php index de66aca..bc1c668 100644 --- a/authsession.php +++ b/authsession.php @@ -25,21 +25,21 @@ class authsession extends auth @param string $password Password to authenticate */ public function authentication ($email, $password) { - if (!isset ($_SESSION["auth"]["email"]) || - !isset ($_SESSION["auth"]["password"])) + if (!isset ($_SESSION["domframework"]["auth"]["email"]) || + !isset ($_SESSION["domframework"]["auth"]["password"])) throw new Exception ("No previous email in session", 401); - if ($_SESSION["auth"]["email"] !== $email) + if ($_SESSION["domframework"]["auth"]["email"] !== $email) throw new Exception ("Unable to authenticate user '$email'", 401); - if ($_SESSION["auth"]["password"] !== $password) + if ($_SESSION["domframework"]["auth"]["password"] !== $password) throw new Exception ("Bad password for '$email'", 401); } /** Return all the parameters recorded for the authenticate user */ public function getdetails () { - return array ("lastname"=>$_SESSION["auth"]["lastname"], - "firstname"=>$_SESSION["auth"]["firstname"], - "email"=>$_SESSION["auth"]["email"]); + return array ("lastname"=>$_SESSION["domframework"]["auth"]["lastname"], + "firstname"=>$_SESSION["domframework"]["auth"]["firstname"], + "email"=>$_SESSION["domframework"]["auth"]["email"]); } /** Method to change the password : unavailable in SESSION auth @@ -52,4 +52,22 @@ class authsession extends auth "The password can't be change for SESSION users"), 405); } + + /** Save the datas in session */ + public function savedatas ($email, $password, $lastname, $firstname) + { + $_SESSION["domframework"]["auth"]["lastname"] = $lastname; + $_SESSION["domframework"]["auth"]["firstname"] = $firstname; + $_SESSION["domframework"]["auth"]["email"] = $email; + $_SESSION["domframework"]["auth"]["password"] = $password; + } + + /** Remove the informations from the session */ + public function logout () + { + unset ($_SESSION["domframework"]["auth"]["lastname"]); + unset ($_SESSION["domframework"]["auth"]["firstname"]); + unset ($_SESSION["domframework"]["auth"]["email"]); + unset ($_SESSION["domframework"]["auth"]["password"]); + } }