@gingkoo/base-server 0.0.2-alpha.16 → 0.0.2-alpha.17
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.
|
@@ -23,6 +23,13 @@ const appenders = {
|
|
|
23
23
|
compress: false,
|
|
24
24
|
numBackups: 7,
|
|
25
25
|
},
|
|
26
|
+
userlog: {
|
|
27
|
+
type: 'dateFile',
|
|
28
|
+
filename: path.join(config.app.home, 'logs', 'user.log'),
|
|
29
|
+
pattern: 'yyyy-MM-dd.log',
|
|
30
|
+
compress: false,
|
|
31
|
+
numBackups: 7,
|
|
32
|
+
},
|
|
26
33
|
|
|
27
34
|
infolog: {
|
|
28
35
|
type: 'dateFile',
|
|
@@ -59,6 +66,10 @@ const categories = {
|
|
|
59
66
|
appenders: ['console', 'wslog'],
|
|
60
67
|
level: 'debug',
|
|
61
68
|
},
|
|
69
|
+
userlog: {
|
|
70
|
+
appenders: ['console', 'userlog'],
|
|
71
|
+
level: 'debug',
|
|
72
|
+
},
|
|
62
73
|
|
|
63
74
|
schedulelog: {
|
|
64
75
|
appenders: ['console', 'schedulelog'],
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
const jwt = require('../../utils/jwt');
|
|
3
3
|
const config = require('../../config/index');
|
|
4
|
+
const { userlog } = require('../logger');
|
|
4
5
|
const { loginType, getLoginMethod } = require('../services/login');
|
|
5
6
|
|
|
6
7
|
// 后端登录
|
|
@@ -102,8 +103,10 @@ function setTokenCookies(res, token) {
|
|
|
102
103
|
expires.setDate(expires.getDate() + config.jwt.exp);
|
|
103
104
|
|
|
104
105
|
if (config.jwt.domain) {
|
|
106
|
+
userlog.info(`domain: ${config.jwt.domain}`);
|
|
105
107
|
return res.cookie('X-Token', token, { expires, domain: config.jwt.domain });
|
|
106
108
|
} else {
|
|
109
|
+
userlog.info('不用 domain');
|
|
107
110
|
return res.cookie('X-Token', token, { expires });
|
|
108
111
|
}
|
|
109
112
|
}
|
package/backend/routers/app.js
CHANGED
|
@@ -3,6 +3,7 @@ var express = require('express');
|
|
|
3
3
|
const nodemailer = require('nodemailer');
|
|
4
4
|
const bcrypt = require('bcryptjs');
|
|
5
5
|
const config = require('../config');
|
|
6
|
+
const { userlog } = require('../../backend/common/logger');
|
|
6
7
|
const jwt = require('../utils/jwt');
|
|
7
8
|
const { checkLogin, setTokenCookies } = require('../common/middleware/auth');
|
|
8
9
|
const { join, readFileContent } = require('../utils/path');
|
|
@@ -43,6 +44,8 @@ router.post('/login', async (req, res) => {
|
|
|
43
44
|
userid: userinfo?.USER_ID,
|
|
44
45
|
});
|
|
45
46
|
|
|
47
|
+
userlog.info(`用户:${userinfo?.USER_ID} 登录成功,token: ${token}`);
|
|
48
|
+
|
|
46
49
|
setTokenCookies(res, token);
|
|
47
50
|
res.sendOk({
|
|
48
51
|
token,
|