2 Commits 92c9b5167b ... d5afba3fbf

Author SHA1 Message Date
  Max F d5afba3fbf Merge branch 'master' of ssh://gogs.karmas.fr/KarmaSolutions/KarmaFW 4 years ago
  Max F 7f969852a1 dev 2021-02 4 years ago
2 changed files with 15 additions and 2 deletions
  1. 9 0
      src/App/Middlewares/UrlRouter.php
  2. 6 2
      src/Routing/Controllers/WebAppController.php

+ 9 - 0
src/App/Middlewares/UrlRouter.php

@@ -97,6 +97,15 @@ class UrlRouter
 				return $response->html($error_message, $error_code);
 			}
 
+			// ERROR 403
+			if (in_array($error_code, [401, 403])) {
+				// if $error_code is a 403 page not found
+				if (empty($error_message)) {
+					$error_message = '<title>Access denied</title><h1>Access denied</h1><p>Page access denied</p>';
+				}
+				return $response->html($error_message, $error_code);
+			}
+
 
 			// ERROR 500
 

+ 6 - 2
src/Routing/Controllers/WebAppController.php

@@ -97,7 +97,8 @@ class WebAppController extends AppController
 			}
 
 			//$template->display($error_template);
-			return $this->response->html( $template->fetch($error_template) , $http_status);
+			//return $this->response->html( $template->fetch($error_template) , $http_status);
+			$response_content = $template->fetch($error_template);
 
 		} else {
 			//header("HTTP/1.0 " . $http_status . " " . $meta_title);
@@ -121,9 +122,12 @@ class WebAppController extends AppController
 
 			//echo $output_html;
 
-			return $this->response->html($output_html, $http_status);
+			//return $this->response->html($output_html, $http_status);
+			$response_content = $output_html;
 		}
 
+		
+		throw new \Exception($response_content, $http_status);
 	}
 
 	protected function showError400($title = 'Bad request', $message = '')