Skip to content

Commit

Permalink
feat(desktop): Add real-name restrictions
Browse files Browse the repository at this point in the history
  • Loading branch information
HUAHUAI23 committed Feb 12, 2025
1 parent ce4a525 commit 6dbd7cf
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
14 changes: 14 additions & 0 deletions frontend/desktop/src/pages/api/account/enterpriseRealName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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(`
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Real Name Authentication</title>
<style>
body, html {
height: 100%;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
}
h1 {
text-align: center;
color: #ff0000; /* Red color for error message */
}
</style>
</head>
<body>
<h1>Real name information has been used</h1>
</body>
</html>
`);
}

if (realNameAuthReward) {
await globalPrisma.$transaction(async (globalPrisma) => {
const currentAccount = await globalPrisma.account.findUniqueOrThrow({
Expand Down

0 comments on commit 6dbd7cf

Please sign in to comment.