summaryrefslogtreecommitdiff
path: root/api/db/_updateAuthenticator.ts
diff options
context:
space:
mode:
authorJoe Carstairs <jcarstairs@scottlogic.com>2024-01-22 16:27:58 +0000
committerJoe Carstairs <jcarstairs@scottlogic.com>2024-01-29 10:51:49 +0000
commiteac3fb00ef11c08a277dd8f9e2684b79f15193c2 (patch)
tree1560e57bb5872d698565dc502aa7659d89c830a4 /api/db/_updateAuthenticator.ts
parentaf44cac699b0591eba908db3835c4e5792303095 (diff)
Authenticator db functions use Uint8Array type for id, public_key fields
Diffstat (limited to 'api/db/_updateAuthenticator.ts')
-rw-r--r--api/db/_updateAuthenticator.ts6
1 files changed, 3 insertions, 3 deletions
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<Authenticator, 'id'>
->(id: string, updatedFields: Pick<Authenticator, T>): Promise<void> {
+>(id: Authenticator['id'], updatedFields: Pick<Authenticator, T>): Promise<void> {
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}`);
}
}