From edb10bc37356932796c6f74b536cd708c563498a Mon Sep 17 00:00:00 2001 From: limbo Date: Wed, 12 Feb 2025 14:04:01 +0800 Subject: [PATCH] feat(desktop): Add real-name restrictions (#5368) --- .../pages/api/account/enterpriseRealName.ts | 14 ++++++ .../api/account/faceIdRealNameAuthCallback.ts | 49 ++++++++++++++++++- 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/frontend/desktop/src/pages/api/account/enterpriseRealName.ts b/frontend/desktop/src/pages/api/account/enterpriseRealName.ts index 8f99a5242..b82a2ab6d 100644 --- a/frontend/desktop/src/pages/api/account/enterpriseRealName.ts +++ b/frontend/desktop/src/pages/api/account/enterpriseRealName.ts @@ -193,6 +193,20 @@ async function handlePost( const data = validationResult.data; + const enterprise = await globalPrisma.enterpriseRealNameInfo.findFirst({ + where: { + enterpriseName: data.keyName, + isVerified: true + } + }); + + if (enterprise) { + return jsonRes(res, { + code: 400, + message: 'Enterprise real name information has been used' + }); + } + const globalToken = generateAuthenticationToken({ userUid: payload.userUid, userId: payload.userId, diff --git a/frontend/desktop/src/pages/api/account/faceIdRealNameAuthCallback.ts b/frontend/desktop/src/pages/api/account/faceIdRealNameAuthCallback.ts index 40a1d93de..3bee1fd16 100644 --- a/frontend/desktop/src/pages/api/account/faceIdRealNameAuthCallback.ts +++ b/frontend/desktop/src/pages/api/account/faceIdRealNameAuthCallback.ts @@ -157,7 +157,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) if (!isFaceRecognitionSuccess) { await globalPrisma.userRealNameInfo.update({ - where: { userUid }, + where: { userUid: userUid }, data: { isVerified: false, idVerifyFailedTimes: { increment: 1 }, @@ -194,6 +194,53 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) `); } + const realnameInfo = await globalPrisma.userRealNameInfo.findFirst({ + where: { + realName: userRealNameFaceAuthInfo.Text?.Name, + idCard: userRealNameFaceAuthInfo.Text?.IdCard, + isVerified: true + } + }); + + if (realnameInfo) { + await globalPrisma.userRealNameInfo.update({ + where: { userUid: userUid }, + data: { + isVerified: false, + idVerifyFailedTimes: { increment: 1 }, + additionalInfo: additionalInfo + } + }); + + res.setHeader('Content-Type', 'text/html'); + return res.send(` + + + + + + Real Name Authentication + + + +

Real name information has been used

+ + + `); + } + if (realNameAuthReward) { await globalPrisma.$transaction(async (globalPrisma) => { const currentAccount = await globalPrisma.account.findUniqueOrThrow({