From 19871ee6474975d6803e7f885aca172ed97a3bd1 Mon Sep 17 00:00:00 2001 From: Aswin V Date: Thu, 24 Feb 2022 22:53:35 +0530 Subject: [PATCH] Use email hash to generate id --- pages/api/saml/auth.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pages/api/saml/auth.ts b/pages/api/saml/auth.ts index 7eeb119..903cb9c 100644 --- a/pages/api/saml/auth.ts +++ b/pages/api/saml/auth.ts @@ -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,