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
This commit is contained in:
@@ -25,21 +25,21 @@ class authsession extends auth
|
|||||||
@param string $password Password to authenticate */
|
@param string $password Password to authenticate */
|
||||||
public function authentication ($email, $password)
|
public function authentication ($email, $password)
|
||||||
{
|
{
|
||||||
if (!isset ($_SESSION["auth"]["email"]) ||
|
if (!isset ($_SESSION["domframework"]["auth"]["email"]) ||
|
||||||
!isset ($_SESSION["auth"]["password"]))
|
!isset ($_SESSION["domframework"]["auth"]["password"]))
|
||||||
throw new Exception ("No previous email in session", 401);
|
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);
|
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);
|
throw new Exception ("Bad password for '$email'", 401);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return all the parameters recorded for the authenticate user */
|
/** Return all the parameters recorded for the authenticate user */
|
||||||
public function getdetails ()
|
public function getdetails ()
|
||||||
{
|
{
|
||||||
return array ("lastname"=>$_SESSION["auth"]["lastname"],
|
return array ("lastname"=>$_SESSION["domframework"]["auth"]["lastname"],
|
||||||
"firstname"=>$_SESSION["auth"]["firstname"],
|
"firstname"=>$_SESSION["domframework"]["auth"]["firstname"],
|
||||||
"email"=>$_SESSION["auth"]["email"]);
|
"email"=>$_SESSION["domframework"]["auth"]["email"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Method to change the password : unavailable in SESSION auth
|
/** 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"),
|
"The password can't be change for SESSION users"),
|
||||||
405);
|
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"]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user