mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 15:25:35 +08:00
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:
parent
6aeddad333
commit
a5fc8f3253
|
@ -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;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
|
|
@ -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 %>
|
||||
|
|
Loading…
Reference in New Issue
Block a user