mirror of
https://github.com/open-reception/appointment-booking-software.git
synced 2026-08-17 21:25:52 +02:00
Autosubmit login form on adding passkey (#78)
Co-authored-by: Karl Ludwig Weise <ludwig@ludwigweise.de>
This commit is contained in:
co-authored by
Karl Ludwig Weise
parent
ff315072e3
commit
dc598a5146
@@ -1,15 +1,24 @@
|
||||
import logger from "$lib/logger";
|
||||
|
||||
export const arrayBufferToBase64 = (buffer: ArrayBuffer): string => {
|
||||
const bytes = new Uint8Array(buffer);
|
||||
let binary = "";
|
||||
try {
|
||||
const bytes = new Uint8Array(buffer);
|
||||
let binary = "";
|
||||
|
||||
// Simple loop, no fancy operations
|
||||
for (let i = 0; i < bytes.length; i++) {
|
||||
binary += String.fromCharCode(bytes[i]);
|
||||
// Simple loop, no fancy operations
|
||||
for (let i = 0; i < bytes.length; i++) {
|
||||
binary += String.fromCharCode(bytes[i]);
|
||||
}
|
||||
|
||||
return window.btoa(binary);
|
||||
} catch (error) {
|
||||
logger.error("Failed to convert ArrayBuffer to Base64", {
|
||||
error,
|
||||
notes:
|
||||
"If you see this error locally, the best way to use passkeys is Chromium as of writing this",
|
||||
});
|
||||
throw error;
|
||||
}
|
||||
|
||||
return window.btoa(binary);
|
||||
};
|
||||
|
||||
export const base64UrlToArrayBuffer = (base64url: string) => {
|
||||
|
||||
@@ -120,6 +120,11 @@
|
||||
|
||||
// Update UI to show passkey is ready
|
||||
$passkeyLoading = "success";
|
||||
|
||||
const isValid = await form.validateForm();
|
||||
if (isValid) {
|
||||
form.submit();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user