diff options
Diffstat (limited to 'lib/classes/auth_plugins/StudipAuthAbstract.php')
| -rw-r--r-- | lib/classes/auth_plugins/StudipAuthAbstract.php | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/lib/classes/auth_plugins/StudipAuthAbstract.php b/lib/classes/auth_plugins/StudipAuthAbstract.php index c4f9c73..4859ae6 100644 --- a/lib/classes/auth_plugins/StudipAuthAbstract.php +++ b/lib/classes/auth_plugins/StudipAuthAbstract.php @@ -108,6 +108,8 @@ class StudipAuthAbstract private $config_data = []; + private array $kept_variables = []; + /** * static method to instantiate and retrieve a reference to an object (singleton) * @@ -327,12 +329,22 @@ class StudipAuthAbstract //get configuration array set in local inc if (empty($config)) { $this->plugin_name = strtolower(substr(get_class($this), 10)); - $config = $GLOBALS['STUDIP_AUTH_CONFIG_' . strtoupper($this->plugin_name)]; + $config = $GLOBALS['STUDIP_AUTH_CONFIG_' . strtoupper($this->plugin_name)] ?? []; } //assign each key in the config array as a member of the plugin object foreach ($config as $key => $value) { $this->$key = $value; } + + // Store variables in this instance + // This is needed for the logout where we cannot obtain these variables + // from the session since it is destroyed before the auth's logout is + // called + $this->kept_variables = array_diff_key( + $_SESSION['auth'] ?? [], + $this->getKeptVariables() + + ); } /** @@ -592,4 +604,24 @@ class StudipAuthAbstract { unset($this->config_data[$offset]); } + + /** + * This method returns an associative array containing specific + * variables relevant to the current instance. + */ + public function getKeptVariables(): array + { + return [ + 'auth_plugin' => $this->plugin_name, + ]; + } + + /** + * Returns a variable that was previously kept. Returns null if no content + * could be found. + */ + public function getKeptVariable(string $key): mixed + { + return $this->kept_variables[$key] ?? null; + } } |
