liuyu 4 سال پیش
والد
کامیت
fb5476c26f
1فایلهای تغییر یافته به همراه7 افزوده شده و 7 حذف شده
  1. 7 7
      app/service/login.js

+ 7 - 7
app/service/login.js

@@ -19,7 +19,7 @@ class LoginService extends CrudService {
 
   // 用户登录
   async login(data) {
-    const { phone, passwd, roomId } = data;
+    const { phone, passwd, roomid } = data;
     // 根据用户输入的手机号查询其他用户表中是否存在相应数据
     const user = await this.model.findOne({ phone });
     // 如果用户不存在抛出异常
@@ -37,9 +37,9 @@ class LoginService extends CrudService {
       throw new BusinessError(ErrorCode.ACCESS_DENIED);
     }
     let type = '0';
-    let roomid = '';
-    if (roomId) {
-      const room = await this.roommodel.findOne({ name: roomId });
+    const roomid_ = '';
+    if (roomid) {
+      const room = await this.roommodel.findOne({ name: roomid });
       if (!room) {
         throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '房间号不存在');
       }
@@ -63,7 +63,7 @@ class LoginService extends CrudService {
       }
     }
     user.menus = JSON.stringify(_menus);
-    const newdata = { ...JSON.parse(JSON.stringify(user)), type, roomid, roomname: roomId };
+    const newdata = { ...JSON.parse(JSON.stringify(user)), type, roomid_, roomname: roomid };
     const token = await this.createJwt(newdata);
     await this.app.redis.set(key, token, 'EX', 60 * 60 * 24);
     return { key };
@@ -77,10 +77,10 @@ class LoginService extends CrudService {
   }
 
   // 创建登录Token
-  async createJwt({ id, name, uid, phone, role, menus, remark, openid, deptname, type, roroomid, roomname }) {
+  async createJwt({ id, name, uid, phone, role, menus, remark, openid, deptname, type, roomid, roomname }) {
     const { secret, expiresIn = '1d', issuer = role } = this.config.jwt;
     const subject = phone;
-    const res = { id, uid, name, phone, role, menus, openid, remark, deptname, type, roroomid, roomname };
+    const res = { id, uid, name, phone, role, menus, openid, remark, deptname, type, roomid, roomname };
     const token = await jwt.sign(res, secret, { expiresIn, issuer, subject });
     return token;
   }