Skip to content

Commit

Permalink
Merge pull request #4774 from rubyforgood/4765-fix-500-error-on-404
Browse files Browse the repository at this point in the history
Fix 404 errors showing up as 500 errors
  • Loading branch information
awwaiid authored Nov 11, 2024
2 parents f6d11b4 + e8a5858 commit ba99d54
Show file tree
Hide file tree
Showing 10 changed files with 817 additions and 281 deletions.
9 changes: 0 additions & 9 deletions app/controllers/errors_controller.rb

This file was deleted.

3 changes: 0 additions & 3 deletions app/views/errors/insufficient.html.erb

This file was deleted.

28 changes: 0 additions & 28 deletions app/views/errors/internal_server_error.html.erb

This file was deleted.

31 changes: 0 additions & 31 deletions app/views/errors/not_found.html.erb

This file was deleted.

1 change: 0 additions & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class Application < Rails::Application
config.load_defaults 7.0
config.legacy_connection_handling = false
config.action_dispatch.return_only_media_type_on_content_type = false
config.exceptions_app = routes

config.active_job.queue_adapter = :delayed_job

Expand Down
3 changes: 0 additions & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ def set_up_flipper
end
end

match "/404", to: "errors#not_found", via: :all
match "/500", to: "errors#internal_server_error", via: :all

resources :users do
get :switch_to_role, on: :collection
post :partner_user_reset_password, on: :collection
Expand Down
256 changes: 205 additions & 51 deletions public/403.html
Original file line number Diff line number Diff line change
@@ -1,66 +1,220 @@
<!DOCTYPE html>
<!-- BEGIN app/views/layouts/application.html.erb --><!DOCTYPE html>
<html>
<head>
<title>The page you were looking for is forbidden (403)</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
margin: 0;
}
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Humanessentials</title>
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<meta name="csrf-param" content="authenticity_token" />
<meta name="csrf-token" content="GEbzHx0O7dyJyQZzL93uhkqraqqtHOh_TD11-RAFfsPee7YqjDmGKd7Xq0aPGKX1yz8a_kCEfoUCsn6BgGTiig" />
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/select2.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/build/toastr.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/all.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/v4-shims.css" rel="stylesheet">

div.dialog {
width: 95%;
max-width: 33em;
margin: 4em auto 0;
<link rel="stylesheet" href="/assets/application.css" media="all" />
<script type="importmap" data-turbo-track="reload">{
"imports": {
"jquery": "https://ga.jspm.io/npm:[email protected]/dist/jquery.js",
"admin-lte": "/assets/adminlte.js",
"application": "/assets/application.js",
"startup": "/assets/startup.js",
"@hotwired/turbo-rails": "/assets/turbo.min.js",
"@hotwired/stimulus": "/assets/stimulus.min.js",
"@hotwired/stimulus-loading": "/assets/stimulusloading.js",
"bootstrap": "/assets/bootstrap.min.js",
"popper": "/assets/popper.js",
"highcharts": "https://ga.jspm.io/npm:[email protected]/highcharts.js",
"select2": "https://cdn.jsdelivr.net/npm/[email protected]/dist/js/select2.min.js",
"trix": "https://ga.jspm.io/npm:[email protected]/dist/trix.esm.min.js",
"@rails/actiontext": "https://ga.jspm.io/npm:@rails/[email protected]/app/assets/javascripts/actiontext.js",
"luxon": "https://ga.jspm.io/npm:[email protected]/build/cjs-browser/luxon.js",
"litepicker": "https://cdn.jsdelivr.net/npm/litepicker/dist/litepicker.js",
"litepicker/ranges": "https://cdn.jsdelivr.net/npm/litepicker/dist/plugins/ranges.js",
"toastr": "https://ga.jspm.io/npm:[email protected]/toastr.js",
"@fullcalendar/core": "https://ga.jspm.io/npm:@fullcalendar/[email protected]/index.js",
"preact": "https://ga.jspm.io/npm:[email protected]/dist/preact.module.js",
"preact/compat": "https://ga.jspm.io/npm:[email protected]/compat/dist/compat.module.js",
"preact/hooks": "https://ga.jspm.io/npm:[email protected]/hooks/dist/hooks.module.js",
"@fullcalendar/luxon": "https://ga.jspm.io/npm:@fullcalendar/[email protected]/index.js",
"@fullcalendar/core/": "https://ga.jspm.io/npm:@fullcalendar/[email protected]/",
"@fullcalendar/daygrid": "https://ga.jspm.io/npm:@fullcalendar/[email protected]/index.js",
"@fullcalendar/list": "https://ga.jspm.io/npm:@fullcalendar/[email protected]/index.js",
"quagga": "https://ga.jspm.io/npm:[email protected]/dist/quagga.min.js",
"@rails/ujs": "https://ga.jspm.io/npm:@rails/[email protected]/lib/assets/compiled/rails-ujs.js",
"filterrific": "/assets/filterrific.js",
"bootstrap-select": "https://ga.jspm.io/npm:[email protected]/dist/js/bootstrap-select.js",
"jquery-ui": "https://ga.jspm.io/npm:[email protected]/ui/widget.js",
"controllers/application": "/assets/controllers/application.js",
"controllers/area_served_controller": "/assets/controllers/area_served_controller.js",
"controllers/checkbox_with_nested_element_controller": "/assets/controllers/checkbox_with_nested_element_controller.js",
"controllers/confirmation_controller": "/assets/controllers/confirmation_controller.js",
"controllers/distribution_delivery_controller": "/assets/controllers/distribution_delivery_controller.js",
"controllers/double_select_controller": "/assets/controllers/double_select_controller.js",
"controllers/form_input_controller": "/assets/controllers/form_input_controller.js",
"controllers/highchart_controller": "/assets/controllers/highchart_controller.js",
"controllers": "/assets/controllers/index.js",
"controllers/item_units_controller": "/assets/controllers/item_units_controller.js",
"controllers/password_visibility_controller": "/assets/controllers/password_visibility_controller.js",
"controllers/select2_controller": "/assets/controllers/select2_controller.js",
"controllers/served_area_controller": "/assets/controllers/served_area_controller.js",
"controllers/turbo_controller": "/assets/controllers/turbo_controller.js",
"utils/barcode_items": "/assets/utils/barcode_items.js",
"utils/barcode_scan": "/assets/utils/barcode_scan.js",
"utils/deadline_day_pickers": "/assets/utils/deadline_day_pickers.js",
"utils/distributions_and_transfers": "/assets/utils/distributions_and_transfers.js",
"utils/donations": "/assets/utils/donations.js",
"utils/purchases": "/assets/utils/purchases.js"
}
}</script>
<link rel="modulepreload" href="https://ga.jspm.io/npm:[email protected]/dist/jquery.js">
<link rel="modulepreload" href="/assets/adminlte.js">
<link rel="modulepreload" href="/assets/application.js">
<link rel="modulepreload" href="/assets/startup.js">
<link rel="modulepreload" href="/assets/turbo.min.js">
<link rel="modulepreload" href="/assets/stimulus.min.js">
<link rel="modulepreload" href="/assets/stimulusloading.js">
<link rel="modulepreload" href="/assets/bootstrap.min.js">
<link rel="modulepreload" href="/assets/popper.js">
<link rel="modulepreload" href="https://ga.jspm.io/npm:[email protected]/highcharts.js">
<link rel="modulepreload" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/select2.min.js">
<link rel="modulepreload" href="https://ga.jspm.io/npm:[email protected]/dist/trix.esm.min.js">
<link rel="modulepreload" href="https://ga.jspm.io/npm:@rails/[email protected]/app/assets/javascripts/actiontext.js">
<link rel="modulepreload" href="https://ga.jspm.io/npm:[email protected]/build/cjs-browser/luxon.js">
<link rel="modulepreload" href="https://cdn.jsdelivr.net/npm/litepicker/dist/litepicker.js">
<link rel="modulepreload" href="https://cdn.jsdelivr.net/npm/litepicker/dist/plugins/ranges.js">
<link rel="modulepreload" href="https://ga.jspm.io/npm:[email protected]/toastr.js">
<link rel="modulepreload" href="https://ga.jspm.io/npm:@fullcalendar/[email protected]/index.js">
<link rel="modulepreload" href="https://ga.jspm.io/npm:[email protected]/dist/preact.module.js">
<link rel="modulepreload" href="https://ga.jspm.io/npm:[email protected]/compat/dist/compat.module.js">
<link rel="modulepreload" href="https://ga.jspm.io/npm:[email protected]/hooks/dist/hooks.module.js">
<link rel="modulepreload" href="https://ga.jspm.io/npm:@fullcalendar/[email protected]/index.js">
<link rel="modulepreload" href="https://ga.jspm.io/npm:@fullcalendar/[email protected]/">
<link rel="modulepreload" href="https://ga.jspm.io/npm:@fullcalendar/[email protected]/index.js">
<link rel="modulepreload" href="https://ga.jspm.io/npm:@fullcalendar/[email protected]/index.js">
<link rel="modulepreload" href="https://ga.jspm.io/npm:[email protected]/dist/quagga.min.js">
<link rel="modulepreload" href="https://ga.jspm.io/npm:@rails/[email protected]/lib/assets/compiled/rails-ujs.js">
<link rel="modulepreload" href="/assets/filterrific.js">
<link rel="modulepreload" href="https://ga.jspm.io/npm:[email protected]/dist/js/bootstrap-select.js">
<link rel="modulepreload" href="https://ga.jspm.io/npm:[email protected]/ui/widget.js">
<link rel="modulepreload" href="/assets/controllers/application.js">
<link rel="modulepreload" href="/assets/controllers/area_served_controller.js">
<link rel="modulepreload" href="/assets/controllers/checkbox_with_nested_element_controller.js">
<link rel="modulepreload" href="/assets/controllers/confirmation_controller.js">
<link rel="modulepreload" href="/assets/controllers/distribution_delivery_controller.js">
<link rel="modulepreload" href="/assets/controllers/double_select_controller.js">
<link rel="modulepreload" href="/assets/controllers/form_input_controller.js">
<link rel="modulepreload" href="/assets/controllers/highchart_controller.js">
<link rel="modulepreload" href="/assets/controllers/index.js">
<link rel="modulepreload" href="/assets/controllers/item_units_controller.js">
<link rel="modulepreload" href="/assets/controllers/password_visibility_controller.js">
<link rel="modulepreload" href="/assets/controllers/select2_controller.js">
<link rel="modulepreload" href="/assets/controllers/served_area_controller.js">
<link rel="modulepreload" href="/assets/controllers/turbo_controller.js">
<link rel="modulepreload" href="/assets/utils/barcode_items.js">
<link rel="modulepreload" href="/assets/utils/barcode_scan.js">
<link rel="modulepreload" href="/assets/utils/deadline_day_pickers.js">
<link rel="modulepreload" href="/assets/utils/distributions_and_transfers.js">
<link rel="modulepreload" href="/assets/utils/donations.js">
<link rel="modulepreload" href="/assets/utils/purchases.js">
<script type="module">import "application"</script>

div.dialog > div {
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 12% 0;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
<script type="esms-options">
{
"noLoadEventRetriggers": true
}
</script>

h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">

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);
}
</style>
<meta name="turbo-visit-control" content="reload">
<meta name="turbo-cache-control" content="no-cache">
</head>
<body data-turbo="" data-controller='turbo'
id="errors" class="not_found hold-transition sidebar-mini layout-fixed">
<!-- Site wrapper -->
<div class="wrapper">
<nav class="main-header navbar navbar-expand navbar-white navbar-light">
<a id="collapse" href="#" data-widget="pushmenu" data-auto-collapse-size="992">
<i class="fa fa-bars"></i>
</a>

<ul class="navbar-nav ml-auto">
<div class="navbar-custom-menu">
<ul class="nav navbar-nav">
<li class="user user-menu">
<a rel="nofollow" class=" btn btn-danger btn-md " data-method="delete" href="/users/sign_out"><i class="fa fa-sign-out"></i> Log out</a>
</li>
</ul>
</div>
</ul>
</nav>

<!-- Main Sidebar Container -->
<aside class="main-sidebar sidebar-dark-primary elevation-4">

<!-- Sidebar -->
<div class="sidebar">
<nav class="mt-2">
</nav>
</div>
</aside>

<div class="content-wrapper">
<!-- BEGIN app/views/shared/_flash.html.erb --><turbo-frame id="flash"></turbo-frame><!-- END app/views/shared/_flash.html.erb -->

<body>
<!-- This file lives in public/403.html -->
<div class="dialog">
<div>
<h1>The page you were looking for is forbidden.</h1>
<!-- BEGIN app/views/errors/not_found.html.erb --><section class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1>403 Error Page</h1>
</div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="#">Home</a></li>
<li class="breadcrumb-item active">403 Error Page</li>
</ol>
</div>
</div>
</div>
</section>

<!-- Main content -->
<section class="content">
<div class="error-page">
<h2 class="headline text-warning"> 403</h2>
<br>
<div class="error-content">
<h3><i class="fas fa-exclamation-triangle text-warning"></i> Oops! The page you were looking for is forbidden.</h3>

<p>
You don't have access to this page.
</p>
<h1></h1>
</div>
</div>
</section>
<!-- END app/views/errors/not_found.html.erb -->
</div>
<p>If you are the application owner check the logs for more information.</p>
</div>

<footer class="main-footer">
<div class="pull-right hidden-xs">
</div>
<strong>Human Essentials was built with <i class="fa fa-heart fa-beat" style="color:red;"></i> by <a href="http://rubyforgood.org">Ruby for Good</a>.</strong>
</footer>

</aside>
<div class="control-sidebar-bg"></div>
</div>

</body>
<div class="modal fade" id="modal_new" role="dialog"></div>
</html>
<!-- END app/views/layouts/application.html.erb -->
Loading

0 comments on commit ba99d54

Please sign in to comment.