From db4c2798ae7ab88d6745cfc7d8827d636a7d3ba3 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Mon, 3 Oct 2022 10:49:52 -0400 Subject: Allow redirection after login (#4654) Before, if you've tried to reach a page without being logged, you'll be automatically redirected to the index page after login. Now, the original page is used after login. Fix #3663 --- lib/Minz/Request.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/Minz/Request.php') diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php index 2ad02014f..62d042f28 100644 --- a/lib/Minz/Request.php +++ b/lib/Minz/Request.php @@ -15,6 +15,8 @@ class Minz_Request { private static $default_controller_name = 'index'; private static $default_action_name = 'index'; + private static $originalRequest; + /** * Getteurs */ @@ -92,6 +94,9 @@ class Minz_Request { 'params' => self::$params, ); } + public static function originalRequest() { + return self::$originalRequest; + } public static function modifiedCurrentRequest(array $extraParams = null) { $currentRequest = self::currentRequest(); if (null !== $extraParams) { @@ -327,6 +332,10 @@ class Minz_Request { * > sinon, le dispatcher recharge en interne */ public static function forward($url = array(), $redirect = false) { + if (Minz_Request::originalRequest() === null && strpos('auth', json_encode($url)) !== false) { + self::$originalRequest = $url; + } + if (!is_array($url)) { header('Location: ' . $url); exit(); -- cgit v1.2.3