Skip to content

A platform for community discussion. Free, open, simple.

FIX: Render detailed_404 page from 403 responses

Kane Yorkf25c55b5be1e
diff --git a/app/assets/javascripts/discourse/app/controllers/exception.js b/app/assets/javascripts/discourse/app/controllers/exception.js
index 0057782817c..d4a285b1f14 100644
--- a/app/assets/javascripts/discourse/app/controllers/exception.js
+++ b/app/assets/javascripts/discourse/app/controllers/exception.js
@@ -51,6 +51,9 @@ export default Controller.extend({
isServer: gte("thrown.status", 500),
isUnknown: none("isNetwork", "isServer"),
+ // Handling for the detailed_404 setting (which actually creates 403s)
+ errorHtml: alias("thrown.responseJSON.extras.html"),
+
// TODO
// make ajax requests to /srv/status with exponential backoff
// if one succeeds, set networkFixed to true, which puts a "Fixed!" message on the page
diff --git a/app/assets/javascripts/discourse/app/templates/exception.hbs b/app/assets/javascripts/discourse/app/templates/exception.hbs
index 99d6e459a9a..41555d71012 100644
--- a/app/assets/javascripts/discourse/app/templates/exception.hbs
+++ b/app/assets/javascripts/discourse/app/templates/exception.hbs
@@ -1,22 +1,26 @@
<div class="container">
- <div class="error-page">
- <div class="face">:(</div>
- <div class="reason">{{reason}}</div>
- <div class="url">
- {{i18n "errors.prev_page"}} <a href={{requestUrl}} data-auto-route="true">{{requestUrl}}</a>
- </div>
- <div class="desc">
- {{#if networkFixed}}
- {{d-icon "check-circle"}}
- {{/if}}
+ {{#if (and this.errorHtml this.isForbidden)}}
+ <div class="not-found">{{html-safe this.errorHtml}}</div>
+ {{else}}
+ <div class="error-page">
+ <div class="face">:(</div>
+ <div class="reason">{{reason}}</div>
+ <div class="url">
+ {{i18n "errors.prev_page"}} <a href={{requestUrl}} data-auto-route="true">{{requestUrl}}</a>
+ </div>
+ <div class="desc">
+ {{#if networkFixed}}
+ {{d-icon "check-circle"}}
+ {{/if}}
- {{desc}}
- </div>
- <div class="buttons">
- {{#each enabledButtons as |buttonData|}}
- {{d-button icon=buttonData.icon action=buttonData.action label=buttonData.key class=buttonData.classes}}
- {{/each}}
- {{conditional-loading-spinner condition=loading}}
+ {{desc}}
+ </div>
+ <div class="buttons">
+ {{#each enabledButtons as |buttonData|}}
+ {{d-button icon=buttonData.icon action=buttonData.action label=buttonData.key class=buttonData.classes}}
+ {{/each}}
+ {{conditional-loading-spinner condition=loading}}
+ </div>
</div>
- </div>
+ {{/if}}
</div>
diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb
index 72508092ee5..8ba80d6cfda 100644
--- a/app/controllers/categories_controller.rb
+++ b/app/controllers/categories_controller.rb
@@ -214,6 +214,7 @@ class CategoriesController < ApplicationController
'not in group',
@category,
custom_message: 'not_in_group.title_category',
+ custom_message_params: { group: group.name },
group: group
)
else
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index dd99be5d7fc..4213fa98393 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -297,7 +297,7 @@ en:
invalid_whisper_access: "Either whispers are not enabled or you do not have access to create whisper posts"
not_in_group:
title_topic: "You need to request membership to the '%{group}' group to see this topic."
- title_category: "You must be in a group to see this category."
+ title_category: "You need to request membership to the '%{group}' group to see this category."
request_membership: "Request Membership"
join_group: "Join Group"
deleted_topic: "Oops! This topic has been deleted and is no longer available."