diff options
| author | 2022-10-03 10:49:52 -0400 | |
|---|---|---|
| committer | 2022-10-03 16:49:52 +0200 | |
| commit | db4c2798ae7ab88d6745cfc7d8827d636a7d3ba3 (patch) | |
| tree | 6f27479f6443855f06c9264e9f36d6c1cb321e70 /lib/Minz/Url.php | |
| parent | a9d4c789311ee54f10ff2b483ad8804bd1de5286 (diff) | |
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
Diffstat (limited to 'lib/Minz/Url.php')
| -rw-r--r-- | lib/Minz/Url.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/Minz/Url.php b/lib/Minz/Url.php index d6af50364..0780a636f 100644 --- a/lib/Minz/Url.php +++ b/lib/Minz/Url.php @@ -128,6 +128,40 @@ class Minz_Url { return $url_checked; } + + public static function serialize($url = []) { + try { + return base64_encode(json_encode($url, JSON_THROW_ON_ERROR)); + } catch (\Throwable $exception) { + return ''; + } + } + + public static function unserialize($url = '') { + try { + return json_decode(base64_decode($url), true, JSON_THROW_ON_ERROR); + } catch (\Throwable $exception) { + return ''; + } + } + + /** + * Returns an array representing the URL as passed in the address bar + * @return array URL representation + */ + public static function build () { + $url = [ + 'c' => $_GET['c'] ?? Minz_Request::defaultControllerName(), + 'a' => $_GET['a'] ?? Minz_Request::defaultActionName(), + 'params' => $_GET, + ]; + + // post-traitement + unset($url['params']['c']); + unset($url['params']['a']); + + return $url; + } } /** |
