Re: [Galette-discussion] HTTPS

[ Thread Index | Date Index | More lists.galette.eu/users Archives ]


Salut,

Merci de répondre à la liste ;)

Le 03/12/2018 à 18:03, Bruno Desroches a écrit :
> merci,
> et donc, il faudrait que je fasse la mise à jour ultime ?

Heu... Quand la 0.9.2 sera sortie (pas de date), le correctif sera intégré.

En attendant je met en pièce jointe un patch applicable en 0.9.1.

++

PS: du coup, j'ai également retrouvé l'URL du post du forum :
https://forums.galette.eu/viewtopic.php?id=89
-- 
Johan
From bd9f9b7fbadff6f4317a44aa86d0d4c3d23b3f66 Mon Sep 17 00:00:00 2001
From: Johan Cwiklinski <johan@xxxxxxxx>
Date: Mon, 3 Dec 2018 21:31:06 +0100
Subject: [PATCH] Fix redirections for 0.8.

---
 galette/includes/main.inc.php | 33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/galette/includes/main.inc.php b/galette/includes/main.inc.php
index 4f67c072..9f93a958 100644
--- a/galette/includes/main.inc.php
+++ b/galette/includes/main.inc.php
@@ -267,7 +267,7 @@ $baseRedirect = function ($request, $response, $args = []) use ($app, $container
     if ($login->isLogged()) {
         $urlRedirect = null;
         if ($session->urlRedirect !== null) {
-            $urlRedirect = $request->getUri()->getBaseUrl() . $session->urlRedirect;
+            $urlRedirect = getGaletteBaseUrl($request) . $session->urlRedirect;
             $session->urlRedirect = null;
         }
 
@@ -286,28 +286,51 @@ $baseRedirect = function ($request, $response, $args = []) use ($app, $container
                     return $response
                         ->withStatus(301)
                         //Do not use "$router->pathFor('dashboard'))" to prevent translation issues when login
-                        ->withHeader('Location', $request->getUri()->getBaseUrl() . __('/dashboard', 'routes'));
+                        ->withHeader('Location', getGaletteBaseUrl($request) . __('/dashboard', 'routes'));
                 } else {
                     return $response
                         ->withStatus(301)
                         //Do not use "$router->pathFor('members'))" to prevent translation issues when login
-                        ->withHeader('Location', $request->getUri()->getBaseUrl() . __('/members', 'routes'));
+                        ->withHeader('Location', getGaletteBaseUrl($request) . __('/members', 'routes'));
                 }
             } else {
                 return $response
                     ->withStatus(301)
                     //Do not use "$router->pathFor('me'))" to prevent translation issues when login
-                    ->withHeader('Location', $request->getUri()->getBaseUrl() . __('/dashboard', 'routes'));
+                    ->withHeader('Location', getGaletteBaseUrl($request) . __('/dashboard', 'routes'));
             }
         }
     } else {
         return $response
             ->withStatus(301)
             //Do not use "$router->pathFor('login'))" to prevent translation issues when login
-            ->withHeader('Location', $request->getUri()->getBaseUrl() . __('/login', 'routes'));
+            ->withHeader('Location', getGaletteBaseUrl($request) . __('/login', 'routes'));
     }
 };
 
+/**
+ * Get base URL fixed for proxies
+ *
+ * @param Request $request request to work on
+ *
+ * @return string
+ */
+function getGaletteBaseUrl(\Slim\Http\Request $request)
+{
+    $url = preg_replace(
+        [
+            '|index\.php|',
+            '|'.$_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . '(:\d+)?' . '|'
+        ],
+        ['', ''],
+        $request->getUri()->getBaseUrl()
+    );
+    if (strlen($url) && substr($url, -1) !== '/') {
+        $url .= '/';
+    }
+    return $url;
+}
+
 /**
  * Get current URI
  *
-- 
2.19.2

Attachment: signature.asc
Description: OpenPGP digital signature



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/