diff options
| author | Joe Carstairs <jcarstairs@scottlogic.com> | 2024-01-22 14:59:51 +0000 |
|---|---|---|
| committer | Joe Carstairs <jcarstairs@scottlogic.com> | 2024-01-29 10:51:49 +0000 |
| commit | 19b4835bea200099bae15bc02edd5e4cafa2c46c (patch) | |
| tree | f58a0124b361c16b51a55ebe68fcf52845438270 /api/db/_deleteUserAuthenticators.ts | |
| parent | edcb9577e28dc312f48d5ab3f5ecc8eeffd8db56 (diff) | |
verifyRegistrationResponse is single-responsibility!
Diffstat (limited to 'api/db/_deleteUserAuthenticators.ts')
| -rw-r--r-- | api/db/_deleteUserAuthenticators.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/api/db/_deleteUserAuthenticators.ts b/api/db/_deleteUserAuthenticators.ts new file mode 100644 index 0000000..32f4ea5 --- /dev/null +++ b/api/db/_deleteUserAuthenticators.ts @@ -0,0 +1,16 @@ +import { sql } from '@vercel/postgres'; +import { AUTHENTICATORS } from './_tables'; +import User from '../types/User'; + +export default async function deleteUserAuthenticators(userId: User['id']) { + const query = ` + DELETE FROM ${AUTHENTICATORS.name} + WHERE ${AUTHENTICATORS.fields.id} = '${id}'; + `; + + try { + await sql.query(query); + } catch (err) { + throw new Error(`Failed to delete authenticators for user with ID ${userId} from database. Query was ${query.replace(/\s+/g, ' ')}. ${err}`); + } +} |
