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:
Robin Ward 2014-03-05 11:48:06 -05:00
parent 2a99f1b15e
commit b0f3061113
3 changed files with 15 additions and 2 deletions

View File

@ -524,10 +524,16 @@ Discourse.Composer = Discourse.Model.extend({
postStream.undoPost(createdPost);
}
composer.set('composeState', OPEN);
// TODO extract error handling code
var parsedError;
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) {
parsedError = "Unknown error saving post, try again. Error: " + error.status + " " + error.statusText;

View File

@ -86,7 +86,13 @@ class ApplicationController < ActionController::Base
rescue_from Discourse::NotLoggedIn do |e|
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
rescue_from Discourse::NotFound do

View File

@ -33,6 +33,7 @@ en:
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_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."
too_many_replies: