@shun-js/user 0.3.3 → 0.3.4
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/package.json +2 -2
- package/server/service/UserItemService.js +5 -42
- package/server/util/user.js +62 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shun-js/user",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "user",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shun.js",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"access": "public",
|
|
35
35
|
"registry": "https://registry.npmjs.org/"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "ff2465fb870eea80a1447911e3bfbe8121b5ed28"
|
|
38
38
|
}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
const { AESEncrypt } = require('qiao-encode');
|
|
3
3
|
|
|
4
4
|
// model
|
|
5
|
-
const {
|
|
5
|
+
const { getUserItemById } = require('../model/UserItemModel.js');
|
|
6
6
|
|
|
7
|
-
//
|
|
8
|
-
const {
|
|
7
|
+
// util
|
|
8
|
+
const { loginORRegUser } = require('../util/user.js');
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* userLogin
|
|
@@ -48,45 +48,8 @@ exports.userLogin = async (req, res) => {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
// user item
|
|
51
|
-
const
|
|
52
|
-
if (!
|
|
53
|
-
|
|
54
|
-
// reg
|
|
55
|
-
if (getUserItemRes.length !== 1) {
|
|
56
|
-
// add user
|
|
57
|
-
const addUserItemRes = await addUserItem(req, res, mobile);
|
|
58
|
-
if (!addUserItemRes) return;
|
|
59
|
-
|
|
60
|
-
// feishu
|
|
61
|
-
const finalMsg = `【提醒】success - ${methodName} - new user reg - ${addUserItemRes.id}`;
|
|
62
|
-
const feishuBotRes = await feishuBot({
|
|
63
|
-
url: global.QZ_CONFIG.feishu.url,
|
|
64
|
-
feishuUrl: global.QZ_CONFIG.feishu.feishuUrl,
|
|
65
|
-
feishuMsg: finalMsg,
|
|
66
|
-
});
|
|
67
|
-
req.logger.warn(methodName, 'feishuBotRes', feishuBotRes);
|
|
68
|
-
|
|
69
|
-
// r
|
|
70
|
-
res.jsonSuccess('登录成功!', addUserItemRes);
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// login
|
|
75
|
-
const user = getUserItemRes[0];
|
|
76
|
-
const userItem = {
|
|
77
|
-
id: user.id,
|
|
78
|
-
usertoken: AESEncrypt(mobile + user.user_item_password, global.QZ_CONFIG.encryptKey),
|
|
79
|
-
usermobile: mobile,
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
// feishu
|
|
83
|
-
const finalMsg = `【提醒】success - ${methodName} - user login - ${userItem.id}`;
|
|
84
|
-
const feishuBotRes = await feishuBot({
|
|
85
|
-
url: global.QZ_CONFIG.feishu.url,
|
|
86
|
-
feishuUrl: global.QZ_CONFIG.feishu.feishuUrl,
|
|
87
|
-
feishuMsg: finalMsg,
|
|
88
|
-
});
|
|
89
|
-
req.logger.warn(methodName, 'feishuBotRes', feishuBotRes);
|
|
51
|
+
const userItem = await loginORRegUser(mobile);
|
|
52
|
+
if (!userItem) return;
|
|
90
53
|
|
|
91
54
|
// r
|
|
92
55
|
res.jsonSuccess('登录成功!', userItem);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// qiao
|
|
2
|
+
const { AESEncrypt } = require('qiao-encode');
|
|
3
|
+
|
|
4
|
+
// model
|
|
5
|
+
const { getUserItemByName, addUserItem } = require('../model/UserItemModel.js');
|
|
6
|
+
|
|
7
|
+
// feishu
|
|
8
|
+
const { feishuBot } = require('@shun-js/shun-service');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* loginORRegUser
|
|
12
|
+
* @param {*} req
|
|
13
|
+
* @param {*} res
|
|
14
|
+
* @param {*} mobileOREmail
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
exports.loginORRegUser = async (req, res, mobileOREmail) => {
|
|
18
|
+
const methodName = 'loginORRegUser';
|
|
19
|
+
|
|
20
|
+
// user item
|
|
21
|
+
const getUserItemRes = await getUserItemByName(req, res, mobileOREmail);
|
|
22
|
+
if (!getUserItemRes) return;
|
|
23
|
+
|
|
24
|
+
// reg
|
|
25
|
+
if (getUserItemRes.length !== 1) {
|
|
26
|
+
// add user
|
|
27
|
+
const addUserItemRes = await addUserItem(req, res, mobileOREmail);
|
|
28
|
+
if (!addUserItemRes) return;
|
|
29
|
+
|
|
30
|
+
// feishu
|
|
31
|
+
const finalMsg = `【提醒】success - ${methodName} - new user reg - ${addUserItemRes.id}`;
|
|
32
|
+
const feishuBotRes = await feishuBot({
|
|
33
|
+
url: global.QZ_CONFIG.feishu.url,
|
|
34
|
+
feishuUrl: global.QZ_CONFIG.feishu.feishuUrl,
|
|
35
|
+
feishuMsg: finalMsg,
|
|
36
|
+
});
|
|
37
|
+
req.logger.warn(methodName, 'feishuBotRes', feishuBotRes);
|
|
38
|
+
|
|
39
|
+
// r
|
|
40
|
+
return addUserItemRes;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// login
|
|
44
|
+
const user = getUserItemRes[0];
|
|
45
|
+
const userItem = {
|
|
46
|
+
id: user.id,
|
|
47
|
+
usertoken: AESEncrypt(mobileOREmail + user.user_item_password, global.QZ_CONFIG.encryptKey),
|
|
48
|
+
usermobile: mobileOREmail,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// feishu
|
|
52
|
+
const finalMsg = `【提醒】success - ${methodName} - user login - ${userItem.id}`;
|
|
53
|
+
const feishuBotRes = await feishuBot({
|
|
54
|
+
url: global.QZ_CONFIG.feishu.url,
|
|
55
|
+
feishuUrl: global.QZ_CONFIG.feishu.feishuUrl,
|
|
56
|
+
feishuMsg: finalMsg,
|
|
57
|
+
});
|
|
58
|
+
req.logger.warn(methodName, 'feishuBotRes', feishuBotRes);
|
|
59
|
+
|
|
60
|
+
// r
|
|
61
|
+
return userItem;
|
|
62
|
+
};
|