Implemented phase 5 for the POC prototype in the Website service.
This commit is contained in:
1 parent
89a7a7b8e5
commit
31d2d98d49
46 files changed
+4039
-162
No files matched your search
@@ -1,4 +1,4 @@
|
||||
// CCN — passkey sign-in. Without it, or without WebAuthn, the sign-in screen offers the demo sign-in alone.
|
||||
// CCN — passkeys: signing in or joining, and adding one from the account screen. Without it, or without WebAuthn, the demo sign-in remains.
|
||||
|
||||
const form = document.querySelector("[data-passkey-form]");
|
||||
const supported = window.PublicKeyCredential
|
||||
@@ -30,7 +30,10 @@ if (form && supported) {
|
||||
status.textContent = "";
|
||||
|
||||
try {
|
||||
const { mode, options } = await post("/sign-in/passkey/options", { email: form.elements.email.value });
|
||||
// On the account screen the button adds a passkey to the account signed in; on the sign-in screen it signs in or joins.
|
||||
const adding = button.dataset.passkey === "add";
|
||||
const start = adding ? { add: true } : { email: form.querySelector("[name=email]").value };
|
||||
const { mode, options } = await post("/sign-in/passkey/options", start);
|
||||
let credential;
|
||||
|
||||
if (mode === "create") {
|
||||
@@ -47,7 +50,7 @@ if (form && supported) {
|
||||
|
||||
const { location } = await post("/sign-in/passkey/finish", {
|
||||
credential: credential.toJSON(),
|
||||
return: form.elements.return.value,
|
||||
return: form.querySelector("[name=return]")?.value,
|
||||
});
|
||||
|
||||
window.location.assign(location);
|
||||
|
||||
Reference in new issue
Block a user