authentication : allow logout to provide a url to be displayed after successful logout
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3390 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -79,8 +79,10 @@ class authentication
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
/** Disconnect the user
|
/** Disconnect the user
|
||||||
|
* @param string|null $url The url to be redirected after a valid
|
||||||
|
* logout
|
||||||
*/
|
*/
|
||||||
public function logout ()
|
public function logout ($url = "")
|
||||||
{
|
{
|
||||||
if ($this->debug) echo "<pre>LOGOUT\n";
|
if ($this->debug) echo "<pre>LOGOUT\n";
|
||||||
$authsession = new \authsession ();
|
$authsession = new \authsession ();
|
||||||
@@ -91,12 +93,17 @@ class authentication
|
|||||||
"Logout for '".$param["email"]."'");
|
"Logout for '".$param["email"]."'");
|
||||||
$authsession->logout ();
|
$authsession->logout ();
|
||||||
unset ($_SESSION["domframework"]["authentication"]);
|
unset ($_SESSION["domframework"]["authentication"]);
|
||||||
$_SESSION["domframework"]["authentication"]["message"] =
|
|
||||||
dgettext("domframework", "You have been logged out");
|
|
||||||
if ($this->debug) echo "Redirect to authentication page";
|
if ($this->debug) echo "Redirect to authentication page";
|
||||||
if ($this->debug) $this->route->debug = $this->debug;
|
if ($this->debug) $this->route->debug = $this->debug;
|
||||||
|
if ($url === "")
|
||||||
|
{
|
||||||
|
$_SESSION["domframework"]["authentication"]["message"] =
|
||||||
|
dgettext("domframework", "You have been logged out");
|
||||||
$this->route->redirect ("/authentication", "");
|
$this->route->redirect ("/authentication", "");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
$this->route->redirect ($url);
|
||||||
|
}
|
||||||
|
|
||||||
/** Display the login page
|
/** Display the login page
|
||||||
* @param string|null $url The url to be redirected after a valid
|
* @param string|null $url The url to be redirected after a valid
|
||||||
@@ -344,9 +351,9 @@ class authentication
|
|||||||
$authObj = $this;
|
$authObj = $this;
|
||||||
$route=$this->route;
|
$route=$this->route;
|
||||||
$this->route
|
$this->route
|
||||||
->get ("authentication/logout", function () use ($authObj)
|
->get ("authentication/logout({url})?", function ($url) use ($authObj)
|
||||||
{
|
{
|
||||||
$authObj->logout ();
|
$authObj->logout ($url);
|
||||||
})
|
})
|
||||||
|
|
||||||
->get ("authentication", function () use ($route)
|
->get ("authentication", function () use ($route)
|
||||||
|
|||||||
Reference in New Issue
Block a user