]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/front/ShaarliMiddleware.php
Fix basePath in unit tests reference DB
[github/shaarli/Shaarli.git] / application / front / ShaarliMiddleware.php
index 595182ac324d1f8a4cb699cbe71c1fcfa9b67039..707489d065b0951b125738464e5ba8af553fb465 100644 (file)
@@ -56,13 +56,15 @@ class ShaarliMiddleware
         } catch (ShaarliFrontException $e) {
             // Possible functional error
             $this->container->pageBuilder->reset();
-            $this->container->pageBuilder->assign('message', $e->getMessage());
+            $this->container->pageBuilder->assign('message', nl2br($e->getMessage()));
 
             $response = $response->withStatus($e->getCode());
 
-            return $response->write($this->container->pageBuilder->render('error'));
+            return $response->write($this->container->pageBuilder->render('error', $this->container->basePath));
         } catch (UnauthorizedException $e) {
-            return $response->withRedirect($this->container->basePath . '/login');
+            $returnUrl = urlencode($this->container->environment['REQUEST_URI']);
+
+            return $response->withRedirect($this->container->basePath . '/login?returnurl=' . $returnUrl);
         } catch (\Throwable $e) {
             // Unknown error encountered
             $this->container->pageBuilder->reset();
@@ -78,7 +80,7 @@ class ShaarliMiddleware
 
             $response = $response->withStatus(500);
 
-            return $response->write($this->container->pageBuilder->render('error'));
+            return $response->write($this->container->pageBuilder->render('error', $this->container->basePath));
         }
     }
 
@@ -91,6 +93,7 @@ class ShaarliMiddleware
             return;
         }
 
+        $this->container->updater->setBasePath($this->container->basePath);
         $newUpdates = $this->container->updater->update();
         if (!empty($newUpdates)) {
             $this->container->updater->writeUpdates(