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:
2017-03-08 14:58:58 +00:00
parent 4a0b30782d
commit fef2cfddc6

View File

@@ -79,8 +79,10 @@ class authentication
}*/
/** 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";
$authsession = new \authsession ();
@@ -91,12 +93,17 @@ class authentication
"Logout for '".$param["email"]."'");
$authsession->logout ();
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) $this->route->debug = $this->debug;
if ($url === "")
{
$_SESSION["domframework"]["authentication"]["message"] =
dgettext("domframework", "You have been logged out");
$this->route->redirect ("/authentication", "");
}
else
$this->route->redirect ($url);
}
/** Display the login page
* @param string|null $url The url to be redirected after a valid
@@ -344,9 +351,9 @@ class authentication
$authObj = $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)