@@ -738,10 +738,17 @@ router.post('/verify', authLimiter, async (req, res) => {
738
738
throw new Error ( 'Secret key is empty' )
739
739
const username = await checkUserVerify ( token )
740
740
const user = await getUser ( username )
741
- if ( user != null && user . status === Status . Normal ) {
742
- res . send ( { status : 'Fail' , message : '账号已存在 | The email exists' , data : null } )
743
- return
744
- }
741
+ if ( user == null )
742
+ throw new Error ( '账号不存在 | The email not exists' )
743
+ if ( user . status === Status . Deleted )
744
+ throw new Error ( '账号已禁用 | The email has been blocked' )
745
+ if ( user . status === Status . Normal )
746
+ throw new Error ( '账号已存在 | The email exists' )
747
+ if ( user . status === Status . AdminVerify )
748
+ throw new Error ( '请等待管理员开通 | Please wait for the admin to activate' )
749
+ if ( user . status !== Status . PreVerify )
750
+ throw new Error ( '账号异常 | Account abnormality' )
751
+
745
752
const config = await getCacheConfig ( )
746
753
let message = '验证成功 | Verify successfully'
747
754
if ( config . siteConfig . registerReview ) {
@@ -766,10 +773,11 @@ router.post('/verifyadmin', authLimiter, async (req, res) => {
766
773
throw new Error ( 'Secret key is empty' )
767
774
const username = await checkUserVerifyAdmin ( token )
768
775
const user = await getUser ( username )
769
- if ( user != null && user . status === Status . Normal ) {
770
- res . send ( { status : 'Fail' , message : '账户已开通 | The email has been opened.' , data : null } )
771
- return
772
- }
776
+ if ( user == null )
777
+ throw new Error ( '账号不存在 | The email not exists' )
778
+ if ( user . status !== Status . AdminVerify )
779
+ throw new Error ( `账号异常 ${ user . status } | Account abnormality ${ user . status } ` )
780
+
773
781
await verifyUser ( username , Status . Normal )
774
782
await sendNoticeMail ( username )
775
783
res . send ( { status : 'Success' , message : '账户已激活 | Account has been activated.' , data : null } )
0 commit comments