Skip to content

Commit

Permalink
Initialize multifxn button on passkey btn
Browse files Browse the repository at this point in the history
  • Loading branch information
Lupe Camacho authored and Lupe Camacho committed Aug 20, 2024
1 parent f7afc10 commit 556e652
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js.map

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions src/web/assets/cp/src/js/LoginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Craft.LoginForm = Garnish.Base.extend(
$errors: null,
$altMethodContainer: null,
$passkeyBtn: null,
passkeyBtn: null,

modal: null,
resetPasswordForm: null,
Expand Down Expand Up @@ -47,6 +48,7 @@ Craft.LoginForm = Garnish.Base.extend(
this.submitBtn = new Garnish.MultiFunctionBtn(this.$submitBtn, {
changeButtonText: true,
});
this.passkeyBtn = new Garnish.MultiFunctionBtn(this.$passkeyBtn);

this.$spinner = document.createElement('craft-spinner');
this.$spinner.setAttribute('visible', false);
Expand Down Expand Up @@ -319,7 +321,7 @@ Craft.LoginForm = Garnish.Base.extend(
return;
}

this.$passkeyBtn.addClass('loading');
this.passkeyBtn.busyEvent();

try {
const optionsResponse = await Craft.sendActionRequest(
Expand All @@ -340,14 +342,18 @@ Craft.LoginForm = Garnish.Base.extend(
}
);

this.passkeyBtn.successEvent();
this.settings.onLogin(loginResponse.data.returnUrl);
} catch (e) {
const message = e?.response?.data?.message;

this.passkeyBtn.failureEvent();

if (message) {
this.showError(message);
}
} finally {
this.$passkeyBtn.removeClass('loading');
this.passkeyBtn.endBusyState();
}
},
},
Expand Down

0 comments on commit 556e652

Please sign in to comment.