diff --git a/src/UnicaenAuth/Authentication/Storage/AuthFactory.php b/src/UnicaenAuth/Authentication/Storage/AuthFactory.php index 7c5c1c4a03769cb0efa4cbc1368902aa2d546d63..c90334bb70c2ae2a165e79c3845b4a4f4ff7c4c6 100644 --- a/src/UnicaenAuth/Authentication/Storage/AuthFactory.php +++ b/src/UnicaenAuth/Authentication/Storage/AuthFactory.php @@ -4,6 +4,7 @@ namespace UnicaenAuth\Authentication\Storage; use Interop\Container\ContainerInterface; use Laminas\Authentication\Storage\Session; +use Laminas\Session\Exception\RuntimeException; use Laminas\Session\SessionManager; class AuthFactory @@ -19,7 +20,18 @@ class AuthFactory $sessionManager = $container->get(SessionManager::class); $storage = new Auth(); - $storage->setStorage(new Session(Usurpation::class, null, $sessionManager)); + + try { + $storage->setStorage(new Session(Usurpation::class, null, $sessionManager)); + } catch (RuntimeException $e) { + /** + * Tentative de réagir en cas d'erreur suivante : + * "PHP Fatal error: Uncaught Zend\Session\Exception\RuntimeException: Session validation failed in + * /var/www/sygal/vendor/zendframework/zend-session/src/SessionManager.php:160" + */ + $sessionManager->regenerateId(true); + $storage->setStorage(new Session(Usurpation::class, null, $sessionManager)); + } return $storage; }