q-koa 7.8.4 → 7.8.5
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 +3 -0
- package/core/config.js +1 -0
- package/core/file/plugins/user/controller.js +23 -5
- package/package.json +1 -1
package/core/app.js
CHANGED
|
@@ -1736,6 +1736,9 @@ APP.moment = moment
|
|
|
1736
1736
|
global.moment = moment
|
|
1737
1737
|
global.Sequelize = Sequelize
|
|
1738
1738
|
global.lodash = _
|
|
1739
|
+
|
|
1740
|
+
APP.sleep = (time) => new Promise((resolve) => setTimeout(resolve, time * 1000))
|
|
1741
|
+
|
|
1739
1742
|
APP.getService = (name) => {
|
|
1740
1743
|
const target = require(path.resolve(__dirname, `./file/services/${name}`))
|
|
1741
1744
|
return target
|
package/core/config.js
CHANGED
|
@@ -4,12 +4,30 @@ const { getAppByCtx, getConfig } = require('q-koa')
|
|
|
4
4
|
exports.login = async (ctx) => {
|
|
5
5
|
const { app, appName } = getAppByCtx(ctx)
|
|
6
6
|
const { mobile, password, ...rest } = ctx.request.body
|
|
7
|
+
const where =
|
|
8
|
+
process.env.NODE_ENV !== 'production'
|
|
9
|
+
? {
|
|
10
|
+
$or: [
|
|
11
|
+
{
|
|
12
|
+
mobile,
|
|
13
|
+
password: [md5(password), password],
|
|
14
|
+
...rest,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: mobile,
|
|
18
|
+
password: [md5(password), password],
|
|
19
|
+
...rest,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
}
|
|
23
|
+
: {
|
|
24
|
+
mobile,
|
|
25
|
+
password: [md5(password), password],
|
|
26
|
+
...rest,
|
|
27
|
+
}
|
|
28
|
+
|
|
7
29
|
let result = await app.model.user.findOne({
|
|
8
|
-
where
|
|
9
|
-
mobile,
|
|
10
|
-
password: [md5(password), password],
|
|
11
|
-
...rest,
|
|
12
|
-
},
|
|
30
|
+
where,
|
|
13
31
|
})
|
|
14
32
|
if (!result) throw new Error('账号密码错误')
|
|
15
33
|
console.log('user==>', ctx.request[`${appName}-user`])
|