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"]); + } }