FIX: Render detailed_404 page from 403 responses

This was previously broken by 59ef48c0b9 (#11425, #11424).

Centralize the logic into the exception controller, which avoids the problematic bug and makes it easy to add additional detailed 404 pages in the future.
This commit is contained in:
Kane York 2021-06-14 14:42:09 -07:00 committed by Kane York
parent d1b2e9db3b
commit f25c55b5be
4 changed files with 27 additions and 19 deletions

View File

@ -51,6 +51,9 @@ export default Controller.extend({
isServer: gte("thrown.status", 500), isServer: gte("thrown.status", 500),
isUnknown: none("isNetwork", "isServer"), isUnknown: none("isNetwork", "isServer"),
// Handling for the detailed_404 setting (which actually creates 403s)
errorHtml: alias("thrown.responseJSON.extras.html"),
// TODO // TODO
// make ajax requests to /srv/status with exponential backoff // make ajax requests to /srv/status with exponential backoff
// if one succeeds, set networkFixed to true, which puts a "Fixed!" message on the page // if one succeeds, set networkFixed to true, which puts a "Fixed!" message on the page

View File

@ -1,22 +1,26 @@
<div class="container"> <div class="container">
<div class="error-page"> {{#if (and this.errorHtml this.isForbidden)}}
<div class="face">:(</div> <div class="not-found">{{html-safe this.errorHtml}}</div>
<div class="reason">{{reason}}</div> {{else}}
<div class="url"> <div class="error-page">
{{i18n "errors.prev_page"}} <a href={{requestUrl}} data-auto-route="true">{{requestUrl}}</a> <div class="face">:(</div>
</div> <div class="reason">{{reason}}</div>
<div class="desc"> <div class="url">
{{#if networkFixed}} {{i18n "errors.prev_page"}} <a href={{requestUrl}} data-auto-route="true">{{requestUrl}}</a>
{{d-icon "check-circle"}} </div>
{{/if}} <div class="desc">
{{#if networkFixed}}
{{d-icon "check-circle"}}
{{/if}}
{{desc}} {{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>
<div class="buttons"> {{/if}}
{{#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> </div>

View File

@ -214,6 +214,7 @@ class CategoriesController < ApplicationController
'not in group', 'not in group',
@category, @category,
custom_message: 'not_in_group.title_category', custom_message: 'not_in_group.title_category',
custom_message_params: { group: group.name },
group: group group: group
) )
else else

View File

@ -297,7 +297,7 @@ en:
invalid_whisper_access: "Either whispers are not enabled or you do not have access to create whisper posts" invalid_whisper_access: "Either whispers are not enabled or you do not have access to create whisper posts"
not_in_group: not_in_group:
title_topic: "You need to request membership to the '%{group}' group to see this topic." 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" request_membership: "Request Membership"
join_group: "Join Group" join_group: "Join Group"
deleted_topic: "Oops! This topic has been deleted and is no longer available." deleted_topic: "Oops! This topic has been deleted and is no longer available."