devlogin: Fix handling of fragments in the URL.

When a fragment (i.e. section starting with `#`) is present in the URL
when landing the development login page, dev-login.js used to append
it to the appends it to the `formaction` attribute of all the input
tag present in the `dev_login.html`.

This made sense before 139cb8026f, which
adjusted the structure of how `next` was passed.

To fix this, we adjust the JavaScript login to set the `next` hidden
input instead.

fixes #16215
This commit is contained in:
sankalp 2020-09-02 12:51:18 +05:30 committed by Tim Abbott
parent 2befc007cf
commit 737d796e1c
1 changed files with 4 additions and 4 deletions

View File

@ -5,12 +5,12 @@ $(() => {
// dev_login.html is rendered.
if ($("[data-page-id='dev-login']").length > 0) {
if (window.location.hash.substring(0, 1) === "#") {
/* We append the location.hash to the formaction so that URL can be
/* We append the location.hash to the input field with name next so that URL can be
preserved after user is logged in. See this:
https://stackoverflow.com/questions/5283395/url-hash-is-persisting-between-redirects */
$("input[name='direct_email']").each(function () {
const new_formaction = $(this).attr("formaction") + "/" + window.location.hash;
$(this).attr("formaction", new_formaction);
$("input[name='next']").each(function () {
const new_value = $(this).attr("value") + window.location.hash;
$(this).attr("value", new_value);
});
}
}