From 9f89a0bfe612018ddb4228cda150feda41c3288d Mon Sep 17 00:00:00 2001 From: Jan Kristinus Date: Fri, 15 Nov 2024 12:17:57 +0100 Subject: [PATCH] =?UTF-8?q?Injections=20mit=20Level=20f=C3=BCr=20Reihenfol?= =?UTF-8?q?ge=20eingef=C3=BChrt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- boot.php | 6 +++--- plugins/auth/lib/ycom_auth.php | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/boot.php b/boot.php index 75d0406..9b9996f 100644 --- a/boot.php +++ b/boot.php @@ -9,9 +9,9 @@ // include __DIR__.'/vendor/guzzlehttp/guzzle/src/functions_include.php'; // -rex_ycom_auth::addInjection(new rex_ycom_injection_termsofuse()); -rex_ycom_auth::addInjection(new rex_ycom_injection_passwordchange()); -rex_ycom_auth::addInjection(new rex_ycom_injection_otp()); +rex_ycom_auth::addInjection(new rex_ycom_injection_otp(), 1); +rex_ycom_auth::addInjection(new rex_ycom_injection_passwordchange(), 4); +rex_ycom_auth::addInjection(new rex_ycom_injection_termsofuse(), 8); if (rex::isBackend()) { rex_extension::register('PACKAGES_INCLUDED', static function ($params) { diff --git a/plugins/auth/lib/ycom_auth.php b/plugins/auth/lib/ycom_auth.php index 6c95f72..788aa26 100644 --- a/plugins/auth/lib/ycom_auth.php +++ b/plugins/auth/lib/ycom_auth.php @@ -29,14 +29,22 @@ class rex_ycom_auth public static array $injections = []; - public static function addInjection(rex_ycom_injection_abtract $injection): void + public static function addInjection(rex_ycom_injection_abtract $injection, int $level = 1): void { - self::$injections[] = $injection; + self::$injections[$level][] = $injection; // $level][ } public static function getInjections(): array { - return self::$injections; + $injections = []; + ksort(self::$injections); + + foreach (self::$injections as $level => $injection) { + foreach ($injection as $inj) { + $injections[] = $inj; + } + } + return $injections; } public static function getRequestKey(string $requestKey): string @@ -125,6 +133,8 @@ public static function init(): string if (rex_plugin::get('ycom', 'auth')->getConfig('article_id_logout') == rex_article::getCurrentId()) { // ignore rest - because logout is always ok . } else { + // dd(self::getInjections()); + foreach (self::getInjections() as $injection) { $rewrite = $injection->getRewrite(); if ($rewrite && '' != $rewrite) {