mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 10:50:26 -06:00
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
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user