diff options
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}`); + } +} |
