It doesn't make sense to redirect when not logged in on a non-GET
request. We should report a failure then. They likely logged out or in another tab or timed out.
This commit is contained in:
parent
2a99f1b15e
commit
b0f3061113
3 changed files with 15 additions and 2 deletions
app
config/locales
|
@ -524,10 +524,16 @@ Discourse.Composer = Discourse.Model.extend({
|
||||||
postStream.undoPost(createdPost);
|
postStream.undoPost(createdPost);
|
||||||
}
|
}
|
||||||
composer.set('composeState', OPEN);
|
composer.set('composeState', OPEN);
|
||||||
|
|
||||||
// TODO extract error handling code
|
// TODO extract error handling code
|
||||||
var parsedError;
|
var parsedError;
|
||||||
try {
|
try {
|
||||||
parsedError = $.parseJSON(error.responseText).errors[0];
|
var parsedJSON = $.parseJSON(error.responseText);
|
||||||
|
if (parsedJSON.errors) {
|
||||||
|
parsedError = parsedJSON.errors[0];
|
||||||
|
} else if (parsedJSON.failed) {
|
||||||
|
parsedError = parsedJSON.message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(ex) {
|
catch(ex) {
|
||||||
parsedError = "Unknown error saving post, try again. Error: " + error.status + " " + error.statusText;
|
parsedError = "Unknown error saving post, try again. Error: " + error.status + " " + error.statusText;
|
||||||
|
|
|
@ -86,7 +86,13 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
rescue_from Discourse::NotLoggedIn do |e|
|
rescue_from Discourse::NotLoggedIn do |e|
|
||||||
raise e if Rails.env.test?
|
raise e if Rails.env.test?
|
||||||
redirect_to "/"
|
|
||||||
|
if request.get?
|
||||||
|
redirect_to "/"
|
||||||
|
else
|
||||||
|
render status: 403, json: failed_json.merge(message: I18n.t(:not_logged_in))
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
rescue_from Discourse::NotFound do
|
rescue_from Discourse::NotFound do
|
||||||
|
|
|
@ -33,6 +33,7 @@ en:
|
||||||
backup_file_should_be_tar_gz: "The backup file should be a .tar.gz archive."
|
backup_file_should_be_tar_gz: "The backup file should be a .tar.gz archive."
|
||||||
not_enough_space_on_disk: "There is not enough space on disk to upload this backup."
|
not_enough_space_on_disk: "There is not enough space on disk to upload this backup."
|
||||||
|
|
||||||
|
not_logged_in: "You need to be logged in to do that."
|
||||||
read_only_mode_enabled: "The site is in read only mode. Interactions are disabled."
|
read_only_mode_enabled: "The site is in read only mode. Interactions are disabled."
|
||||||
|
|
||||||
too_many_replies:
|
too_many_replies:
|
||||||
|
|
Reference in a new issue