Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(desktop): Add real-name restrictions #5368

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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