Skip to content

Commit 77c8a32

Browse files
author
Kerwin
committed
fix: exception when the account does not exist
1 parent 89951ef commit 77c8a32

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

service/src/index.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -444,17 +444,15 @@ router.post('/user-login', async (req, res) => {
444444
throw new Error('用户名或密码为空 | Username or password is empty')
445445

446446
const user = await getUser(username)
447-
if (user == null
448-
|| user.status !== Status.Normal
449-
|| user.password !== md5(password)) {
450-
if (user.password !== md5(password))
451-
throw new Error('用户不存在或密码错误 | User does not exist or incorrect password.')
452-
if (user != null && user.status === Status.PreVerify)
453-
throw new Error('请去邮箱中验证 | Please verify in the mailbox')
454-
if (user != null && user.status === Status.AdminVerify)
455-
throw new Error('请等待管理员开通 | Please wait for the admin to activate')
447+
if (user == null || user.password !== md5(password))
448+
throw new Error('用户不存在或密码错误 | User does not exist or incorrect password.')
449+
if (user.status === Status.PreVerify)
450+
throw new Error('请去邮箱中验证 | Please verify in the mailbox')
451+
if (user != null && user.status === Status.AdminVerify)
452+
throw new Error('请等待管理员开通 | Please wait for the admin to activate')
453+
if (user.status !== Status.Normal)
456454
throw new Error('账户状态异常 | Account status abnormal.')
457-
}
455+
458456
const config = await getCacheConfig()
459457
const token = jwt.sign({
460458
name: user.name ? user.name : user.email,

0 commit comments

Comments
 (0)