This repository has been archived on 2023-11-14. You can view files and clone it, but cannot push or open issues/pull-requests.
viscord/packages/server/src/lib/validateClientTotp.ts

9 lines
372 B
TypeScript
Raw Normal View History

2022-08-03 20:01:51 -04:00
import query from '../db/query'
import getTotpKey from '../db/snippets/client/getTotpKeyByClientId.sql'
import { validateTotp } from './validateTotp';
export async function validateClientTotp(clientId: string, code: string) {
const res = await query(getTotpKey, clientId);
if(res === null || res.length !== 1) return false;
return validateTotp(res[0].totp, code);
}