Browse Source

🐞 fix: 修复第一个注册用户无管理员权限的问题

Pchen. 7 months ago
parent
commit
d58d998c2c
1 changed files with 1 additions and 3 deletions
  1. 1 3
      apis/User/Login/Register.js

+ 1 - 3
apis/User/Login/Register.js

@@ -95,10 +95,8 @@ class Register extends API {
         // 查询users表中是否有用户
         const userCountQuery = 'SELECT COUNT(*) as count FROM users';
         const userCountResult = await db.query(userCountQuery);
-        const userCount = userCountResult.count;
-
         // 如果是第一个注册的用户 授予admin权限
-        const admin = userCount === 0 ? 1 : 0;
+        const admin = userCountResult[0].count === 0 ? 1 : 0;
 
         const uuid = md5(Date.now() + email + code);
         const session = this.createSession(code, Math.random().toFixed(6).slice(-6));