From eac3fb00ef11c08a277dd8f9e2684b79f15193c2 Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Mon, 22 Jan 2024 16:27:58 +0000 Subject: Authenticator db functions use Uint8Array type for id, public_key fields --- api/db/_updateAuthenticator.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'api/db/_updateAuthenticator.ts') diff --git a/api/db/_updateAuthenticator.ts b/api/db/_updateAuthenticator.ts index a7e06e3..6c72327 100644 --- a/api/db/_updateAuthenticator.ts +++ b/api/db/_updateAuthenticator.ts @@ -5,7 +5,7 @@ import { AUTHENTICATORS } from './_tables'; export default async function updateAuthenticator< T extends keyof Omit ->(id: string, updatedFields: Pick): Promise { +>(id: Authenticator['id'], updatedFields: Pick): Promise { const assignments = Object.entries(updatedFields) .filter(([key]) => key !== 'id') // never update the ID .map(([key, value]) => `${key}=${value}`) @@ -14,12 +14,12 @@ export default async function updateAuthenticator< const query = ` UPDATE ${AUTHENTICATORS.name} SET ${assignments} - WHERE ${AUTHENTICATORS.fields.id} = '${id}'; + WHERE ${AUTHENTICATORS.fields.id} = '{ ${id.toString()} }'; `; try { await sql.query(query); } catch (err) { - throw new Error(`Failed to update authenticator with ID ${id} in database. Query was ${query.replace(/\s+/g, ' ')}. ${err}`); + throw new Error(`Failed to update authenticator with ID [${id.toString()}] in database. Query was ${query.replace(/\s+/g, ' ')}. ${err}`); } } -- cgit v1.2.3