From fef2cfddc6fce83c3cc665e45ef7a3f753836144 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Wed, 8 Mar 2017 14:58:58 +0000 Subject: [PATCH] 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 --- authentication.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/authentication.php b/authentication.php index e82a625..59ef1d3 100644 --- a/authentication.php +++ b/authentication.php @@ -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 "
LOGOUT\n";
     $authsession = new \authsession ();
@@ -91,11 +93,16 @@ 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;
-    $this->route->redirect ("/authentication", "");
+    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
@@ -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)