Use email hash to generate id

This commit is contained in:
Aswin V 2022-02-24 22:53:35 +05:30
parent cc68eca2f8
commit 19871ee647

View File

@ -1,5 +1,6 @@
import config from 'lib/env';
import { createHash } from 'crypto';
import type { NextApiRequest, NextApiResponse } from 'next';
import config from 'lib/env';
import type { User } from 'types';
import {
createResponseForm,
@ -16,8 +17,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
if (!email.endsWith('@example.com')) {
res.status(403).send(`${email} denied access`);
}
const id = email.replace('@example.com', '');
const id = createHash('sha256').update(email).digest('hex');
const user: User = {
id,