FIX: Account activation under ember-5 build (#24722)

We were previously relying on Ember's 'vendor' bundle to make the jquery global available on the activate_account route. That no longer happens under our Ember 5 build.

This commit updates our activate-account script to remove the need for jquery, so that it works under both Ember 3 and Ember 5 builds.
This commit is contained in:
David Taylor 2023-12-05 17:49:40 +00:00 committed by GitHub
parent 6aeddad333
commit a5fc8f3253
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 13 deletions

View File

@ -1,18 +1,27 @@
/* eslint-disable ember/no-global-jquery */
(function () {
const $activateButton = $("#activate-account-button");
$activateButton.on("click", function () {
$activateButton.prop("disabled", true);
const activateButton = document.querySelector("#activate-account-button");
activateButton.addEventListener("click", async function () {
activateButton.setAttribute("disabled", true);
const hpPath = document.getElementById("data-activate-account").dataset
.path;
$.ajax(hpPath)
.then(function (hp) {
$("#password_confirmation").val(hp.value);
$("#challenge").val(hp.challenge.split("").reverse().join(""));
$("#activate-account-form").submit();
})
.fail(function () {
$activateButton.prop("disabled", false);
try {
const response = await fetch(hpPath, {
headers: {
Accept: "application/json",
},
});
const hp = await response.json();
document.querySelector("#password_confirmation").value = hp.value;
document.querySelector("#challenge").value = hp.challenge
.split("")
.reverse()
.join("");
document.querySelector("#activate-account-form").submit();
} catch (e) {
activateButton.removeAttribute("disabled");
throw e;
}
});
})();

View File

@ -12,7 +12,6 @@
</div>
<%- content_for(:no_ember_head) do %>
<%= preload_script "vendor" %>
<%= render_google_universal_analytics_code %>
<%= tag.meta id: 'data-activate-account', data: { path: path('/session/hp') } %>
<%- end %>