FIX: when shown 403 error page and logging in, it will take you to the same page
This commit is contained in:
parent
534dadf1be
commit
7322345039
|
@ -726,7 +726,11 @@ Discourse.PostStream = Em.Object.extend({
|
|||
// If the result is 403 it means invalid access
|
||||
if (status === 403) {
|
||||
topic.set('errorTitle', I18n.t('topic.invalid_access.title'));
|
||||
topic.set('message', I18n.t('topic.invalid_access.description'));
|
||||
if (Discourse.User.current()) {
|
||||
topic.set('message', I18n.t('topic.invalid_access.description'));
|
||||
} else {
|
||||
topic.set('message', I18n.t('topic.invalid_access.login_required'));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -123,9 +123,11 @@
|
|||
{{#if message}}
|
||||
<div class="message">
|
||||
<h2>{{message}}</h2>
|
||||
{{#unless currentUser}}
|
||||
<button {{action showLogin}} class='btn btn-primary btn-small'>{{i18n log_in}}</button>
|
||||
{{/unless}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
</div>
|
||||
{{else}}
|
||||
<div class='container'>
|
||||
|
|
|
@ -94,21 +94,21 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
rescue_from Discourse::InvalidAccess do
|
||||
rescue_discourse_actions("[error: 'invalid access']", 403) # TODO: this breaks json responses
|
||||
rescue_discourse_actions("[error: 'invalid access']", 403, true) # TODO: this breaks json responses
|
||||
end
|
||||
|
||||
rescue_from Discourse::ReadOnly do
|
||||
render status: 405, json: failed_json.merge(message: I18n.t("read_only_mode_enabled"))
|
||||
end
|
||||
|
||||
def rescue_discourse_actions(message, error)
|
||||
def rescue_discourse_actions(message, error, include_ember=false)
|
||||
if request.format && request.format.json?
|
||||
# TODO: this doesn't make sense. Stuffing an html page into a json response will cause
|
||||
# $.parseJSON to fail in the browser. Also returning text like "[error: 'invalid access']"
|
||||
# from the above rescue_from blocks will fail because that isn't valid json.
|
||||
render status: error, layout: false, text: (error == 404) ? build_not_found_page(error) : message
|
||||
else
|
||||
render text: build_not_found_page(error, 'no_js')
|
||||
render text: build_not_found_page(error, include_ember ? 'application' : 'no_js')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -679,6 +679,7 @@ en:
|
|||
invalid_access:
|
||||
title: "Topic is private"
|
||||
description: "Sorry, you don't have access to that topic!"
|
||||
login_required: "You need to log in to see that topic."
|
||||
server_error:
|
||||
title: "Topic failed to load"
|
||||
description: "Sorry, we couldn't load that topic, possibly due to a connection problem. Please try again. If the problem persists, let us know."
|
||||
|
|
Loading…
Reference in New Issue