authparams : take the informations from session with the right name ("domframework)
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1823 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -6,6 +6,31 @@
|
|||||||
/** Takes the email and the password of the user */
|
/** Takes the email and the password of the user */
|
||||||
class authparams
|
class authparams
|
||||||
{
|
{
|
||||||
|
public $email = null;
|
||||||
|
public $password = null;
|
||||||
|
|
||||||
|
/** Parse the different authentication processes to found the email/password
|
||||||
|
of the user.
|
||||||
|
If non is found, return "anonymous", "anonymous" */
|
||||||
|
public function __construct ($authprocesses=array("session","post"))
|
||||||
|
{
|
||||||
|
foreach ($authprocesses as $authprocess)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$res = $this->$authprocess();
|
||||||
|
$this->email = $res["email"];
|
||||||
|
$this->password = $res["password"];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
catch (Exception $e)
|
||||||
|
{
|
||||||
|
$this->email = "anonymous";
|
||||||
|
$this->password = "anonymous";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Get informations from $POST variables */
|
/** Get informations from $POST variables */
|
||||||
public function post()
|
public function post()
|
||||||
{
|
{
|
||||||
@@ -19,11 +44,11 @@ class authparams
|
|||||||
{
|
{
|
||||||
if (!isset ($_SESSION))
|
if (!isset ($_SESSION))
|
||||||
throw new Exception ("No session previously opened", 401);
|
throw new Exception ("No session previously opened", 401);
|
||||||
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);
|
||||||
return array ("email"=>$_SESSION["auth"]["email"],
|
return array ("email"=>$_SESSION["domframework"]["auth"]["email"],
|
||||||
"password"=>$_SESSION["auth"]["email"]);
|
"password"=>$_SESSION["domframework"]["auth"]["password"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get informations from a HTTP authentication */
|
/** Get informations from a HTTP authentication */
|
||||||
@@ -43,4 +68,5 @@ class authparams
|
|||||||
"password"=>$_SERVER["PHP_AUTH_PW"]);
|
"password"=>$_SERVER["PHP_AUTH_PW"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user