Skip to content

A platform for community discussion. Free, open, simple.

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

David Taylora5fc8f325310
diff --git a/app/assets/javascripts/discourse/scripts/activate-account.js b/app/assets/javascripts/discourse/scripts/activate-account.js
index e4a3d07bbe1..0581a40707e 100644
--- a/app/assets/javascripts/discourse/scripts/activate-account.js
+++ b/app/assets/javascripts/discourse/scripts/activate-account.js
@@ -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;
+ }
});
})();
diff --git a/app/views/users/activate_account.html.erb b/app/views/users/activate_account.html.erb
index 34973d66cb4..5c7f8b75a47 100644
--- a/app/views/users/activate_account.html.erb
+++ b/app/views/users/activate_account.html.erb
@@ -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 %>