cheny 4 years ago
parent
commit
462f09de5b
2 changed files with 14 additions and 13 deletions
  1. 6 5
      app/service/login.js
  2. 8 8
      config/config.default.js

+ 6 - 5
app/service/login.js

@@ -94,6 +94,7 @@ class LoginService extends CrudService {
     //   }
     // }
     // user.menus = JSON.stringify(_menus);
+    console.log(user);
     const token = await this.createJwt(user);
     await this.app.redis.set(key, token, 'EX', 60 * 60 * 24);
     return { key };
@@ -107,11 +108,11 @@ class LoginService extends CrudService {
   }
 
   // 创建登录Token
-  async createJwt({ id, name, uid, phone, role, menus, remark, openid, deptid, deptname, pid, code }) {
-    const { secret, expiresIn = '1d', issuer = role } = this.config.jwt;
-    const subject = phone;
-    const res = { uid: id, userid: uid, name, phone, role, menus, openid, remark, deptid, deptname, pid, code };
-    const token = await jwt.sign(res, secret, { expiresIn, issuer, subject });
+  async createJwt(user) {
+    // const { secret, expiresIn = '1d', issuer = role } = this.config.jwt;
+    // const subject = phone;
+    // const res = { uid: id, userid: uid, name, phone, role, menus, openid, remark, deptid, deptname, pid, code };
+    const token = await jwt.sign(user);
     return token;
   }
 

+ 8 - 8
config/config.default.js

@@ -67,14 +67,14 @@ module.exports = appInfo => {
   };
 
   // redis config
-  config.redis = {
-    client: {
-      port: 6379, // Redis port
-      host: '127.0.0.1', // Redis host
-      password: 123456,
-      db: 0,
-    },
-  };
+  // config.redis = {
+  //   client: {
+  //     port: 6379, // Redis port
+  //     host: '127.0.0.1', // Redis host
+  //     password: 123456,
+  //     db: 0,
+  //   },
+  // };
 
   return {
     ...config,