From 378dac716db305359bf7febdb598d81cae302517 Mon Sep 17 00:00:00 2001 From: Kerwin Date: Sat, 24 Jun 2023 17:13:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=B8=8D=E8=83=BD=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=9A=84=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/src/index.ts | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/service/src/index.ts b/service/src/index.ts index 69c1ce0e90..24285dbd97 100644 --- a/service/src/index.ts +++ b/service/src/index.ts @@ -738,10 +738,17 @@ router.post('/verify', authLimiter, async (req, res) => { throw new Error('Secret key is empty') const username = await checkUserVerify(token) const user = await getUser(username) - if (user != null && user.status === Status.Normal) { - res.send({ status: 'Fail', message: '账号已存在 | The email exists', data: null }) - return - } + if (user == null) + throw new Error('账号不存在 | The email not exists') + if (user.status === Status.Deleted) + throw new Error('账号已禁用 | The email has been blocked') + if (user.status === Status.Normal) + throw new Error('账号已存在 | The email exists') + if (user.status === Status.AdminVerify) + throw new Error('请等待管理员开通 | Please wait for the admin to activate') + if (user.status !== Status.PreVerify) + throw new Error('账号异常 | Account abnormality') + const config = await getCacheConfig() let message = '验证成功 | Verify successfully' if (config.siteConfig.registerReview) { @@ -766,10 +773,11 @@ router.post('/verifyadmin', authLimiter, async (req, res) => { throw new Error('Secret key is empty') const username = await checkUserVerifyAdmin(token) const user = await getUser(username) - if (user != null && user.status === Status.Normal) { - res.send({ status: 'Fail', message: '账户已开通 | The email has been opened.', data: null }) - return - } + if (user == null) + throw new Error('账号不存在 | The email not exists') + if (user.status !== Status.AdminVerify) + throw new Error(`账号异常 ${user.status} | Account abnormality ${user.status}`) + await verifyUser(username, Status.Normal) await sendNoticeMail(username) res.send({ status: 'Success', message: '账户已激活 | Account has been activated.', data: null })