From 677751c90677f3922869c255ab2e3466d0b28acd Mon Sep 17 00:00:00 2001 From: David Roetzel Date: Thu, 8 Dec 2022 14:10:02 +0100 Subject: [PATCH] Improve and add static error pages #102 (#114) The 404 and 500 pages have a new design in line with the regular layout of the app, but inlining all css and images, so they are self-contained. In case of a CanCanCan access violation, a 403 page is now being rendered, that matches those other two error pages. --- app/controllers/application_controller.rb | 2 +- public/403.html | 74 ++++++++++++ public/404.html | 126 +++++++++++---------- public/500.html | 131 ++++++++++++---------- 4 files changed, 213 insertions(+), 120 deletions(-) create mode 100644 public/403.html diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index de24ea98..e3942624 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -46,6 +46,6 @@ def display_error_page(error) end def access_denied - head :forbidden + render file: Rails.root.join("public/403.html"), status: :forbidden, layout: false end end diff --git a/public/403.html b/public/403.html new file mode 100644 index 00000000..a6fbf2bc --- /dev/null +++ b/public/403.html @@ -0,0 +1,74 @@ + + + + HDM Forbidden - 403 + + + + + + + +
+
+ 403 +

Forbidden

+

You do not have the rights to access this resource.

+

Please make sure that you are logged in and use the correct user (i.e. an admin user for user and group management, a regular user for everything else).

+ + + + + To Home Page + +
+
+ + + + diff --git a/public/404.html b/public/404.html index 2be3af26..56360334 100644 --- a/public/404.html +++ b/public/404.html @@ -1,67 +1,73 @@ - - - The page you were looking for doesn't exist (404) - - + - .rails-default-error-page h1 { - font-size: 100%; - color: #730E15; - line-height: 1.5em; - } + + - .rails-default-error-page div.dialog > p { - margin: 0 0 1em; - padding: 1em; - background-color: #F7F7F7; - border: 1px solid #CCC; - border-right-color: #999; - border-left-color: #999; - border-bottom-color: #999; - border-bottom-left-radius: 4px; - border-bottom-right-radius: 4px; - border-top-color: #DADADA; - color: #666; - box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17); - } - - +
+
+ 404 +

Not Found

+

Please check the URL for any mistakes.

+ + + + + To Home Page + +
+
- - -
-
-

The page you were looking for doesn't exist.

-

You may have mistyped the address or the page may have moved.

-
-

If you are the application owner check the logs for more information.

-
- + + diff --git a/public/500.html b/public/500.html index 78a030af..34e86e5b 100644 --- a/public/500.html +++ b/public/500.html @@ -1,66 +1,79 @@ - - - We're sorry, but something went wrong (500) - - + - .rails-default-error-page h1 { - font-size: 100%; - color: #730E15; - line-height: 1.5em; - } + + - .rails-default-error-page div.dialog > p { - margin: 0 0 1em; - padding: 1em; - background-color: #F7F7F7; - border: 1px solid #CCC; - border-right-color: #999; - border-left-color: #999; - border-bottom-color: #999; - border-bottom-left-radius: 4px; - border-bottom-right-radius: 4px; - border-top-color: #DADADA; - color: #666; - box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17); - } - - +
+
+ 500 +

Internal Server Error

+

If you are the administrator of this server, please check the hdm log file for the full error message.

+

+ In case the issue persists, please consider opening an issue here: + + https://github.com/betadots/hdm/issues/new + +

+ + + + + To Home Page + +
+
- - -
-
-

We're sorry, but something went wrong.

-
-

If you are the application owner check the logs for more information.

-
- + +