jwtbutler 2.0.8 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_js/_build/script.js +21 -19
- package/package.json +1 -1
package/_js/_build/script.js
CHANGED
|
@@ -358,11 +358,6 @@ var jwtbutler = class {
|
|
|
358
358
|
reject(error);
|
|
359
359
|
});
|
|
360
360
|
this.captchaRender().then(() => {
|
|
361
|
-
let submit = document.querySelector("." + this.config.login_form_class + " form")?.querySelector("button[type=\"submit\"], input[type=\"submit\"]");
|
|
362
|
-
if (submit !== null && submit !== void 0) {
|
|
363
|
-
submit.disabled = false;
|
|
364
|
-
submit.removeAttribute("aria-busy");
|
|
365
|
-
}
|
|
366
361
|
this.triggerLoginFormRenderedEvent();
|
|
367
362
|
}).catch((error) => {
|
|
368
363
|
reject(error);
|
|
@@ -518,21 +513,23 @@ var jwtbutler = class {
|
|
|
518
513
|
sitekey: this.config.captcha.sitekey,
|
|
519
514
|
theme: this.config.captcha.theme || "light"
|
|
520
515
|
};
|
|
516
|
+
if (this.captchaProvider() === "turnstile") options.size = "flexible";
|
|
517
|
+
let setSubmitBlocked = (blocked) => {
|
|
518
|
+
let submit = document.querySelector("." + this.config.login_form_class + " form")?.querySelector("button[type=\"submit\"], input[type=\"submit\"]");
|
|
519
|
+
if (submit === null || submit === void 0) return;
|
|
520
|
+
submit.disabled = blocked;
|
|
521
|
+
if (blocked) {
|
|
522
|
+
submit.setAttribute("aria-busy", "true");
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
submit.removeAttribute("aria-busy");
|
|
526
|
+
};
|
|
527
|
+
options.callback = () => setSubmitBlocked(false);
|
|
528
|
+
options["expired-callback"] = () => setSubmitBlocked(true);
|
|
529
|
+
options["error-callback"] = () => setSubmitBlocked(true);
|
|
521
530
|
if (this.config.language !== "") options[this.captchaVendor().langKey] = this.config.language;
|
|
522
|
-
let widgetLoaded = new Promise((resolveWidget) => {
|
|
523
|
-
let observer = new MutationObserver(() => {
|
|
524
|
-
let iframe = captcha.querySelector("iframe");
|
|
525
|
-
if (iframe === null) return;
|
|
526
|
-
observer.disconnect();
|
|
527
|
-
iframe.addEventListener("load", () => resolveWidget(), { once: true });
|
|
528
|
-
});
|
|
529
|
-
observer.observe(captcha, {
|
|
530
|
-
childList: true,
|
|
531
|
-
subtree: true
|
|
532
|
-
});
|
|
533
|
-
});
|
|
534
531
|
captcha.setAttribute("data-widget-id", this.captchaApi().render(captcha, options));
|
|
535
|
-
|
|
532
|
+
resolve();
|
|
536
533
|
}).catch((error) => {
|
|
537
534
|
reject(error);
|
|
538
535
|
});
|
|
@@ -589,6 +586,11 @@ var jwtbutler = class {
|
|
|
589
586
|
if (!this.captchaEnabled() || !(this.captchaProvider() in window)) return;
|
|
590
587
|
let captcha = form.querySelector("." + this.config.login_form_class + "__captcha");
|
|
591
588
|
if (captcha === null || captcha.getAttribute("data-widget-id") === null) return;
|
|
589
|
+
let submit = form.querySelector("button[type=\"submit\"], input[type=\"submit\"]");
|
|
590
|
+
if (submit !== null) {
|
|
591
|
+
submit.disabled = true;
|
|
592
|
+
submit.setAttribute("aria-busy", "true");
|
|
593
|
+
}
|
|
592
594
|
this.captchaApi().reset(captcha.getAttribute("data-widget-id"));
|
|
593
595
|
}
|
|
594
596
|
bindLoginFormSubmit() {
|
|
@@ -616,7 +618,6 @@ var jwtbutler = class {
|
|
|
616
618
|
cache: "no-cache"
|
|
617
619
|
});
|
|
618
620
|
}).then((res) => res.json()).catch((error) => error).then((response) => {
|
|
619
|
-
if (submit !== null) submit.disabled = false;
|
|
620
621
|
if (response !== void 0 && response !== null && "success" in response && response.success === true) {
|
|
621
622
|
helpers.remove(document.querySelector("." + this.config.login_form_class));
|
|
622
623
|
this.setCookies(response.data.access_token).then(() => {
|
|
@@ -626,6 +627,7 @@ var jwtbutler = class {
|
|
|
626
627
|
reject(error);
|
|
627
628
|
});
|
|
628
629
|
} else {
|
|
630
|
+
if (submit !== null && !this.captchaEnabled()) submit.disabled = false;
|
|
629
631
|
this.removeLoadingStates();
|
|
630
632
|
this.addLoadingState("login-form-visible");
|
|
631
633
|
this.captchaReset(form);
|