liuyu 5 年 前
コミット
de00b55052
1 ファイル変更9 行追加6 行削除
  1. 9 6
      app/service/login.js

+ 9 - 6
app/service/login.js

@@ -45,19 +45,22 @@ class LoginService extends CrudService {
       _userid = _id.toString();
     } else if (type === '1') {
       _userid = uid.toString();
-      res = await this.hModel.findById(_userid);
+      const result = await this.hModel.findById(_userid);
+      res = { userid: _userid, name, type };
     } else if (type === '2') {
       _userid = uid.toString();
-      res = await this.schModel.findById(_userid);
+      const result = await this.schModel.findById(_userid);
+      res = { userid: _userid, code: result.code, name, type };
     } else if (type === '3') {
       _userid = uid.toString();
-      res = await this.tModel.findById(_userid);
+      const result = await this.tModel.findById(_userid);
+      res = { userid: _userid, schid: result.schid, schname: result.schname, name, type };
     } else if (type === '4') {
       _userid = uid.toString();
-      res = await this.stuModel.findById(_userid);
+      const result = await this.stuModel.findById(_userid);
+      res = { userid: _userid, schid: result.schoolid, schname: result.school_name, name, type };
     }
-    const newdata = { userid: _userid, ...res, openid, type };
-    const token = await jwt.sign(newdata, secret, { expiresIn, issuer, subject });
+    const token = await jwt.sign(res, secret, { expiresIn, issuer, subject });
     return token;
   }