q-koa 8.4.0 → 8.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/app.js +23 -6
- package/core/config.js +3 -0
- package/core/file/plugins/administrator/controller.js +11 -1
- package/package.json +3 -2
package/core/app.js
CHANGED
|
@@ -5,6 +5,7 @@ const path = require('path')
|
|
|
5
5
|
const fs = require('fs')
|
|
6
6
|
const fsPromise = require('fs/promises')
|
|
7
7
|
const Sequelize = require('sequelize')
|
|
8
|
+
const redis = require('redis')
|
|
8
9
|
const moment = require('moment')
|
|
9
10
|
const { EventEmitter } = require('events')
|
|
10
11
|
const nodeVm = require('vm')
|
|
@@ -351,13 +352,29 @@ class APP {
|
|
|
351
352
|
const configFile = path.resolve(__dirname, configPath)
|
|
352
353
|
const configExist = fs.existsSync(configFile)
|
|
353
354
|
|
|
354
|
-
this.
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
355
|
+
if (this.config.redis && this.config.redis.url) {
|
|
356
|
+
const client = redis.createClient(this.config.redis)
|
|
357
|
+
client.on('error', (err) => console.log('Redis Client Error', err))
|
|
358
|
+
|
|
359
|
+
await client.connect()
|
|
360
|
+
this.app[appName] = {
|
|
361
|
+
sequelize: db,
|
|
362
|
+
redisClient: client,
|
|
363
|
+
appConfig: _.defaultsDeep(
|
|
364
|
+
configExist ? require(path.resolve(__dirname, configPath)) : {},
|
|
365
|
+
this.config.app
|
|
366
|
+
),
|
|
367
|
+
}
|
|
368
|
+
}else{
|
|
369
|
+
this.app[appName] = {
|
|
370
|
+
sequelize: db,
|
|
371
|
+
appConfig: _.defaultsDeep(
|
|
372
|
+
configExist ? require(path.resolve(__dirname, configPath)) : {},
|
|
373
|
+
this.config.app
|
|
374
|
+
),
|
|
375
|
+
}
|
|
360
376
|
}
|
|
377
|
+
|
|
361
378
|
|
|
362
379
|
// const proxyConfig = _.get(this.app[appName], 'appConfig.proxy');
|
|
363
380
|
// const taskConfig = _.get(this.app[appName], 'appConfig.task', {
|
package/core/config.js
CHANGED
|
@@ -8,13 +8,15 @@ const superAdmin = {
|
|
|
8
8
|
|
|
9
9
|
exports.login = async (ctx) => {
|
|
10
10
|
const { app, appName } = getAppByCtx(ctx)
|
|
11
|
+
const { host } = ctx.request
|
|
11
12
|
const { name, password } = ctx.request.body
|
|
12
|
-
|
|
13
|
+
const is_dev = host.startsWith('localhost')
|
|
13
14
|
const permissionList = await app.model.permission.findAll({
|
|
14
15
|
attributes: {
|
|
15
16
|
exclude: ['createdid', 'updated_at', 'created_at', 'name'],
|
|
16
17
|
},
|
|
17
18
|
})
|
|
19
|
+
if (name === superAdmin.name && !is_dev) throw new Error('账号密码错误')
|
|
18
20
|
if (name === superAdmin.name && password === superAdmin.password) {
|
|
19
21
|
const token = await app.sign({
|
|
20
22
|
user: superAdmin,
|
|
@@ -85,12 +87,20 @@ exports.login = async (ctx) => {
|
|
|
85
87
|
|
|
86
88
|
exports.checkLogin = async (ctx) => {
|
|
87
89
|
const { app, appName } = getAppByCtx(ctx)
|
|
90
|
+
const { host } = ctx.request
|
|
91
|
+
const is_dev = host.startsWith('localhost')
|
|
88
92
|
const permissionList = await app.model.permission.findAll({
|
|
89
93
|
attributes: {
|
|
90
94
|
exclude: ['createdid', 'updated_at', 'created_at', 'name'],
|
|
91
95
|
},
|
|
92
96
|
})
|
|
93
97
|
if (ctx.request[`${appName}-user`]) {
|
|
98
|
+
if (ctx.request[`${appName}-user`].name === superAdmin.name && !is_dev) {
|
|
99
|
+
return ctx.SUCCESS({
|
|
100
|
+
token: null,
|
|
101
|
+
user: null,
|
|
102
|
+
})
|
|
103
|
+
}
|
|
94
104
|
if (ctx.request[`${appName}-user`].name === superAdmin.name) {
|
|
95
105
|
const token = await app.sign({
|
|
96
106
|
user: superAdmin,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "q-koa",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -54,7 +54,8 @@
|
|
|
54
54
|
"wechat-oauth": "^1.5.0",
|
|
55
55
|
"weixin-pay-fork": "^1.0.0",
|
|
56
56
|
"node-uuid": "^1.4.8",
|
|
57
|
-
"sha1": "^1.1.1"
|
|
57
|
+
"sha1": "^1.1.1",
|
|
58
|
+
"redis": "^4.0.3"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
61
|
"eslint": "^4.19.1",
|