FIX: new-topic URL should survive login redirection
This commit is contained in:
parent
04288c14ff
commit
d1632c1dbd
|
@ -78,9 +78,10 @@ export default DiscourseController.extend(ModalFunctionality, {
|
||||||
var destinationUrl = $.cookie('destination_url');
|
var destinationUrl = $.cookie('destination_url');
|
||||||
$hidden_login_form.find('input[name=username]').val(self.get('loginName'));
|
$hidden_login_form.find('input[name=username]').val(self.get('loginName'));
|
||||||
$hidden_login_form.find('input[name=password]').val(self.get('loginPassword'));
|
$hidden_login_form.find('input[name=password]').val(self.get('loginPassword'));
|
||||||
if (self.get('loginRequired') && destinationUrl) {
|
if ((self.get('loginRequired') || $.cookie('shouldRedirectToUrl')) && destinationUrl) {
|
||||||
// redirect client to the original URL
|
// redirect client to the original URL
|
||||||
$.cookie('destination_url', null);
|
$.cookie('destination_url', null);
|
||||||
|
$.cookie('shouldRedirectToUrl', null);
|
||||||
$hidden_login_form.find('input[name=redirect]').val(destinationUrl);
|
$hidden_login_form.find('input[name=redirect]').val(destinationUrl);
|
||||||
} else {
|
} else {
|
||||||
$hidden_login_form.find('input[name=redirect]').val(window.location.href);
|
$hidden_login_form.find('input[name=redirect]').val(window.location.href);
|
||||||
|
|
|
@ -13,6 +13,7 @@ export default Discourse.Route.extend({
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// User is not logged in
|
// User is not logged in
|
||||||
|
$.cookie('shouldRedirectToUrl', true);
|
||||||
self.replaceWith('login');
|
self.replaceWith('login');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,7 @@ class StaticController < ApplicationController
|
||||||
uri.path !~ /\./
|
uri.path !~ /\./
|
||||||
|
|
||||||
destination = uri.path
|
destination = uri.path
|
||||||
|
destination = "#{uri.path}?#{uri.query}" if uri.path =~ /new-topic/
|
||||||
end
|
end
|
||||||
rescue URI::InvalidURIError
|
rescue URI::InvalidURIError
|
||||||
# Do nothing if the URI is invalid
|
# Do nothing if the URI is invalid
|
||||||
|
|
Loading…
Reference in New Issue