Skip to content

Commit

Permalink
fix: 不能验证删除的用户
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerwin committed Jun 24, 2023
1 parent de0b5ec commit 378dac7
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions service/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 })
Expand Down

0 comments on commit 378dac7

Please sign in to comment.