@steedos/accounts 3.0.0-beta.9 → 3.0.0-beta.90
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/lib/core/index.js +66 -26
- package/lib/core/index.js.map +1 -1
- package/lib/rest-express/endpoints/logout.js +79 -72
- package/lib/rest-express/endpoints/logout.js.map +1 -1
- package/lib/rest-express/endpoints/password/change-password.js +94 -89
- package/lib/rest-express/endpoints/password/change-password.js.map +1 -1
- package/lib/rest-express/endpoints/steedos/get-tenant.js +62 -39
- package/lib/rest-express/endpoints/steedos/get-tenant.js.map +1 -1
- package/lib/rest-express/endpoints/steedos/settings.js +119 -88
- package/lib/rest-express/endpoints/steedos/settings.js.map +1 -1
- package/lib/rest-express/user-loader.js +82 -67
- package/lib/rest-express/user-loader.js.map +1 -1
- package/package.json +5 -5
- package/src/core/index.ts +201 -141
- package/src/rest-express/endpoints/logout.ts +74 -72
- package/src/rest-express/endpoints/password/change-password.ts +92 -81
- package/src/rest-express/endpoints/steedos/get-tenant.ts +56 -38
- package/src/rest-express/endpoints/steedos/settings.ts +117 -88
- package/src/rest-express/user-loader.ts +68 -58
package/src/core/index.ts
CHANGED
|
@@ -1,226 +1,286 @@
|
|
|
1
|
-
import { getSteedosConfig } from
|
|
2
|
-
import { db } from
|
|
3
|
-
import * as _ from
|
|
4
|
-
import chalk from
|
|
5
|
-
const clone = require(
|
|
1
|
+
import { getSteedosConfig } from "@steedos/objectql";
|
|
2
|
+
import { db } from "../db";
|
|
3
|
+
import * as _ from "lodash";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
const clone = require("clone");
|
|
6
6
|
|
|
7
7
|
declare var MailQueue;
|
|
8
8
|
declare var SMSQueue;
|
|
9
9
|
|
|
10
10
|
const config = getSteedosConfig();
|
|
11
11
|
|
|
12
|
-
export const getSettings = async ()=>{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
12
|
+
export const getSettings = async () => {
|
|
13
|
+
let tenant = {
|
|
14
|
+
name: "Steedos",
|
|
15
|
+
logo_url: undefined,
|
|
16
|
+
background_url: undefined,
|
|
17
|
+
enable_create_tenant: true,
|
|
18
|
+
enable_register: true,
|
|
19
|
+
enable_forget_password: true,
|
|
20
|
+
enable_password_login: true,
|
|
21
|
+
enable_mobile_code_login: false,
|
|
22
|
+
enable_email_code_login: false,
|
|
23
|
+
enable_bind_mobile: false,
|
|
24
|
+
enable_bind_email: false,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
if (config.tenant) {
|
|
28
|
+
_.assignIn(tenant, config.tenant);
|
|
29
|
+
}
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
if (config.tenant && config.tenant._id) {
|
|
32
|
+
let spaceDoc = await db.findOne("spaces", config.tenant._id, {
|
|
33
|
+
fields: [
|
|
34
|
+
"name",
|
|
35
|
+
"avatar",
|
|
36
|
+
"avatar_dark",
|
|
37
|
+
"background",
|
|
38
|
+
"enable_register",
|
|
39
|
+
],
|
|
40
|
+
});
|
|
41
|
+
let steedosService = getSteedosService();
|
|
42
|
+
if (steedosService && spaceDoc) {
|
|
43
|
+
_.assignIn(tenant, spaceDoc);
|
|
44
|
+
if (spaceDoc.avatar_dark) {
|
|
45
|
+
tenant.logo_url =
|
|
46
|
+
steedosService +
|
|
47
|
+
"api/v6/files/cfs.avatars.filerecord/" +
|
|
48
|
+
spaceDoc.avatar_dark;
|
|
49
|
+
} else if (spaceDoc.avatar) {
|
|
50
|
+
tenant.logo_url =
|
|
51
|
+
steedosService +
|
|
52
|
+
"api/v6/files/cfs.avatars.filerecord/" +
|
|
53
|
+
spaceDoc.avatar;
|
|
29
54
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
_.assignIn(tenant, spaceDoc);
|
|
36
|
-
if (spaceDoc.avatar_dark) {
|
|
37
|
-
tenant.logo_url = steedosService + "api/files/avatars/" + spaceDoc.avatar_dark
|
|
38
|
-
} else if (spaceDoc.avatar) {
|
|
39
|
-
tenant.logo_url = steedosService + "api/files/avatars/" + spaceDoc.avatar
|
|
40
|
-
}
|
|
41
|
-
if (spaceDoc.background) {
|
|
42
|
-
tenant.background_url = steedosService + "api/files/avatars/" + spaceDoc.background
|
|
43
|
-
}
|
|
44
|
-
}
|
|
55
|
+
if (spaceDoc.background) {
|
|
56
|
+
tenant.background_url =
|
|
57
|
+
steedosService +
|
|
58
|
+
"api/v6/files/cfs.avatars.filerecord/" +
|
|
59
|
+
spaceDoc.background;
|
|
45
60
|
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
46
63
|
|
|
47
|
-
|
|
64
|
+
const _tenant = clone(tenant);
|
|
48
65
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
66
|
+
delete _tenant["tokenSecret"];
|
|
67
|
+
delete _tenant["accessTokenExpiresIn"];
|
|
68
|
+
delete _tenant["refreshTokenExpiresIn"];
|
|
52
69
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
70
|
+
return {
|
|
71
|
+
tenant: _tenant,
|
|
72
|
+
password: config.password ? config.password : {},
|
|
73
|
+
root_url: process.env.ROOT_URL,
|
|
74
|
+
};
|
|
75
|
+
};
|
|
59
76
|
|
|
60
|
-
export const getTenant = async (spaceId)=>{
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const spaceDoc = await db.findOne("spaces", spaceId, {fields: ["name", "avatar", "avatar_dark", "background", "enable_register"]})
|
|
77
|
+
export const getTenant = async (spaceId) => {
|
|
78
|
+
if (!spaceId) {
|
|
79
|
+
return {};
|
|
80
|
+
}
|
|
66
81
|
|
|
67
|
-
|
|
68
|
-
|
|
82
|
+
const spaceDoc = await db.findOne("spaces", spaceId, {
|
|
83
|
+
fields: ["name", "avatar", "avatar_dark", "background", "enable_register"],
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
if (!spaceDoc) {
|
|
87
|
+
return {};
|
|
88
|
+
}
|
|
89
|
+
let steedosService = getSteedosService();
|
|
90
|
+
if (steedosService) {
|
|
91
|
+
if (spaceDoc.avatar_dark) {
|
|
92
|
+
spaceDoc.logo_url =
|
|
93
|
+
steedosService +
|
|
94
|
+
"api/v6/files/cfs.avatars.filerecord/" +
|
|
95
|
+
spaceDoc.avatar_dark;
|
|
96
|
+
} else if (spaceDoc.avatar) {
|
|
97
|
+
spaceDoc.logo_url =
|
|
98
|
+
steedosService +
|
|
99
|
+
"api/v6/files/cfs.avatars.filerecord/" +
|
|
100
|
+
spaceDoc.avatar;
|
|
69
101
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
spaceDoc.logo_url = steedosService + "api/files/avatars/" + spaceDoc.avatar
|
|
76
|
-
}
|
|
77
|
-
if (spaceDoc.background) {
|
|
78
|
-
spaceDoc.background_url = steedosService + "api/files/avatars/" + spaceDoc.background
|
|
79
|
-
}
|
|
102
|
+
if (spaceDoc.background) {
|
|
103
|
+
spaceDoc.background_url =
|
|
104
|
+
steedosService +
|
|
105
|
+
"api/v6/files/cfs.avatars.filerecord/" +
|
|
106
|
+
spaceDoc.background;
|
|
80
107
|
}
|
|
108
|
+
}
|
|
81
109
|
|
|
82
|
-
|
|
83
|
-
}
|
|
110
|
+
return spaceDoc;
|
|
111
|
+
};
|
|
84
112
|
|
|
85
|
-
export const spaceExists = async(spaceId)=>{
|
|
86
|
-
const spaceDoc = await db.findOne("spaces", spaceId, {
|
|
87
|
-
|
|
113
|
+
export const spaceExists = async (spaceId) => {
|
|
114
|
+
const spaceDoc = await db.findOne("spaces", spaceId, {
|
|
115
|
+
fields: ["name", "avatar", "avatar_dark", "background", "enable_register"],
|
|
116
|
+
});
|
|
117
|
+
if (spaceDoc) {
|
|
88
118
|
return true;
|
|
89
119
|
}
|
|
90
120
|
return false;
|
|
91
|
-
}
|
|
121
|
+
};
|
|
92
122
|
|
|
93
|
-
export const getMergedTenant = async (spaceId?)=>{
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
123
|
+
export const getMergedTenant = async (spaceId?) => {
|
|
124
|
+
const settings: any = await getSettings();
|
|
125
|
+
const tenant: any = await getTenant(spaceId);
|
|
126
|
+
return Object.assign({}, settings.tenant, tenant);
|
|
127
|
+
};
|
|
98
128
|
|
|
99
|
-
export const canRegister = async (spaceId, action)=>{
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
129
|
+
export const canRegister = async (spaceId, action) => {
|
|
130
|
+
const tenant: any = await getMergedTenant(spaceId);
|
|
131
|
+
if (action === "emailSignupAccount" && !tenant.enable_email_code_login) {
|
|
132
|
+
return false;
|
|
133
|
+
} else if (
|
|
134
|
+
action === "mobileSignupAccount" &&
|
|
135
|
+
!tenant.enable_mobile_code_login
|
|
136
|
+
) {
|
|
137
|
+
return false;
|
|
138
|
+
} else if (action === "withPassword") {
|
|
139
|
+
return (
|
|
140
|
+
tenant.enable_register &&
|
|
141
|
+
tenant.enable_password_login &&
|
|
142
|
+
tenant.disabled_account_register != true
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
return tenant.enable_register && tenant.disabled_account_register != true;
|
|
146
|
+
};
|
|
110
147
|
|
|
111
|
-
export const loginWithCode = async (spaceId)=>{
|
|
148
|
+
export const loginWithCode = async (spaceId) => {
|
|
112
149
|
let loginWithCode = false;
|
|
113
150
|
const tenant: any = await getMergedTenant(spaceId);
|
|
114
|
-
if(tenant.enable_mobile_code_login || tenant.enable_email_code_login){
|
|
151
|
+
if (tenant.enable_mobile_code_login || tenant.enable_email_code_login) {
|
|
115
152
|
loginWithCode = true;
|
|
116
153
|
}
|
|
117
154
|
return loginWithCode;
|
|
118
|
-
}
|
|
155
|
+
};
|
|
119
156
|
|
|
120
|
-
export const canPasswordLogin = async ()=>{
|
|
157
|
+
export const canPasswordLogin = async () => {
|
|
121
158
|
const tenant: any = await getMergedTenant();
|
|
122
159
|
return tenant.enable_password_login;
|
|
123
|
-
}
|
|
160
|
+
};
|
|
124
161
|
|
|
125
|
-
function isEmpty(str){
|
|
126
|
-
if(!str){
|
|
162
|
+
function isEmpty(str) {
|
|
163
|
+
if (!str) {
|
|
127
164
|
return true;
|
|
128
165
|
}
|
|
129
166
|
|
|
130
|
-
if(str ===
|
|
167
|
+
if (str === "undefined") {
|
|
131
168
|
return true;
|
|
132
169
|
}
|
|
133
170
|
|
|
134
|
-
if(_.isString(str) && str.startsWith("${")){
|
|
171
|
+
if (_.isString(str) && str.startsWith("${")) {
|
|
135
172
|
return true;
|
|
136
173
|
}
|
|
137
174
|
|
|
138
175
|
return false;
|
|
139
176
|
}
|
|
140
177
|
|
|
141
|
-
export const canSendEmail = ()=>{
|
|
178
|
+
export const canSendEmail = () => {
|
|
142
179
|
const config = getSteedosConfig().email || {};
|
|
143
180
|
let canSend = true;
|
|
144
181
|
if (!config) {
|
|
145
182
|
canSend = false;
|
|
146
|
-
}else if (isEmpty(config.from)) {
|
|
183
|
+
} else if (isEmpty(config.from)) {
|
|
147
184
|
canSend = false;
|
|
148
|
-
}else if (
|
|
185
|
+
} else if (
|
|
186
|
+
isEmpty(config.url) &&
|
|
187
|
+
(isEmpty(config.host) ||
|
|
188
|
+
isEmpty(config.port) ||
|
|
189
|
+
isEmpty(config.username) ||
|
|
190
|
+
isEmpty(config.password))
|
|
191
|
+
) {
|
|
149
192
|
canSend = false;
|
|
150
193
|
}
|
|
151
194
|
return canSend;
|
|
152
|
-
}
|
|
195
|
+
};
|
|
153
196
|
|
|
154
197
|
//TODO twilio
|
|
155
|
-
export const canSendSMS = ()=>{
|
|
198
|
+
export const canSendSMS = () => {
|
|
156
199
|
const config = (getSteedosConfig().sms || {}).qcloud || {};
|
|
157
200
|
let canSend = true;
|
|
158
201
|
if (!config) {
|
|
159
202
|
canSend = false;
|
|
160
|
-
}else if (
|
|
203
|
+
} else if (
|
|
204
|
+
isEmpty(config.sdkappid) ||
|
|
205
|
+
isEmpty(config.appkey) ||
|
|
206
|
+
isEmpty(config.signname)
|
|
207
|
+
) {
|
|
161
208
|
canSend = false;
|
|
162
209
|
}
|
|
163
210
|
return canSend;
|
|
164
|
-
}
|
|
211
|
+
};
|
|
165
212
|
|
|
166
213
|
export const getRootUrlPathPrefix = (rootUrl) => {
|
|
167
214
|
if (rootUrl) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
215
|
+
var parsedUrl = require("url").parse(rootUrl);
|
|
216
|
+
if (
|
|
217
|
+
!parsedUrl.host ||
|
|
218
|
+
["http:", "https:"].indexOf(parsedUrl.protocol) === -1
|
|
219
|
+
) {
|
|
220
|
+
throw Error("$ROOT_URL, if specified, must be an URL");
|
|
221
|
+
}
|
|
222
|
+
var pathPrefix = parsedUrl.pathname;
|
|
223
|
+
if (pathPrefix.slice(-1) === "/") {
|
|
224
|
+
pathPrefix = pathPrefix.slice(0, -1);
|
|
225
|
+
}
|
|
226
|
+
return pathPrefix;
|
|
177
227
|
} else {
|
|
178
|
-
|
|
228
|
+
return "";
|
|
179
229
|
}
|
|
180
|
-
}
|
|
230
|
+
};
|
|
181
231
|
|
|
182
|
-
export const getSteedosService = ()=>{
|
|
232
|
+
export const getSteedosService = () => {
|
|
183
233
|
let steedosService = getRootUrlPathPrefix(process.env.ROOT_URL);
|
|
184
234
|
if (config.webservices && config.webservices.steedos) {
|
|
185
235
|
if (!config.webservices.steedos.endsWith("/"))
|
|
186
|
-
config.webservices.steedos += "/"
|
|
236
|
+
config.webservices.steedos += "/";
|
|
187
237
|
steedosService = config.webservices.steedos;
|
|
188
238
|
}
|
|
189
|
-
if (!steedosService.endsWith("/"))
|
|
190
|
-
steedosService += "/" ;
|
|
239
|
+
if (!steedosService.endsWith("/")) steedosService += "/";
|
|
191
240
|
return steedosService;
|
|
192
|
-
}
|
|
241
|
+
};
|
|
193
242
|
|
|
194
243
|
export const sendMail = async (mail: any): Promise<void> => {
|
|
195
|
-
const {to, subject, html} = mail;
|
|
244
|
+
const { to, subject, html } = mail;
|
|
196
245
|
const config = getSteedosConfig().email || {};
|
|
197
246
|
let canSend = canSendEmail();
|
|
198
247
|
//如果没有配置发送邮件服务,则打印log
|
|
199
|
-
console.log(chalk.green(`MAIL: ${to}, ${subject}`))
|
|
200
|
-
if(!canSend){
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
248
|
+
console.log(chalk.green(`MAIL: ${to}, ${subject}`));
|
|
249
|
+
if (!canSend) {
|
|
250
|
+
console.log(
|
|
251
|
+
chalk.red(
|
|
252
|
+
"ERROR sending mail, please set email configs in steedos.config.js",
|
|
253
|
+
),
|
|
254
|
+
);
|
|
255
|
+
return;
|
|
256
|
+
} else {
|
|
257
|
+
MailQueue.send({
|
|
258
|
+
to: to,
|
|
259
|
+
from: config.from || "华炎魔方",
|
|
260
|
+
subject: subject,
|
|
261
|
+
html: html,
|
|
262
|
+
});
|
|
210
263
|
}
|
|
211
264
|
};
|
|
212
265
|
|
|
213
266
|
export const sendSMS = async (sms: any): Promise<void> => {
|
|
214
|
-
const {mobile, message, spaceId} = sms;
|
|
267
|
+
const { mobile, message, spaceId } = sms;
|
|
215
268
|
let canSend = canSendSMS();
|
|
216
|
-
console.log(chalk.green(`SMS: ${mobile}, ${message}`))
|
|
217
|
-
if(!canSend){
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
269
|
+
console.log(chalk.green(`SMS: ${mobile}, ${message}`));
|
|
270
|
+
if (!canSend) {
|
|
271
|
+
console.log(
|
|
272
|
+
chalk.red(
|
|
273
|
+
"ERROR sending sms, Please set sms configs in steedos.config.js",
|
|
274
|
+
),
|
|
275
|
+
);
|
|
276
|
+
return;
|
|
277
|
+
} else {
|
|
278
|
+
SMSQueue.send(
|
|
279
|
+
{
|
|
280
|
+
RecNum: mobile,
|
|
281
|
+
msg: message,
|
|
282
|
+
},
|
|
283
|
+
spaceId,
|
|
284
|
+
);
|
|
225
285
|
}
|
|
226
|
-
}
|
|
286
|
+
};
|
|
@@ -3,80 +3,82 @@
|
|
|
3
3
|
* @Date: 2022-03-28 09:35:34
|
|
4
4
|
* @LastEditors: baozhoutao@steedos.com
|
|
5
5
|
* @LastEditTime: 2024-01-23 14:24:35
|
|
6
|
-
* @Description:
|
|
6
|
+
* @Description:
|
|
7
7
|
*/
|
|
8
|
-
import * as express from
|
|
9
|
-
import { get, isEmpty, map } from
|
|
10
|
-
import { AccountsServer } from
|
|
11
|
-
import { sendError } from
|
|
12
|
-
import { clearAuthCookies } from
|
|
13
|
-
import { getObject } from
|
|
14
|
-
import * as requestIp from
|
|
15
|
-
import { getUserAgent } from
|
|
16
|
-
import isMobile from
|
|
17
|
-
import { getSteedosSchema } from
|
|
18
|
-
export const logout =
|
|
19
|
-
|
|
20
|
-
res: express.Response
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
get(req.headers, 'Authorization') ||
|
|
26
|
-
get(req.headers, 'authorization');
|
|
8
|
+
import * as express from "express";
|
|
9
|
+
import { get, isEmpty, map } from "lodash";
|
|
10
|
+
import { AccountsServer } from "../../server";
|
|
11
|
+
import { sendError } from "../utils/send-error";
|
|
12
|
+
import { clearAuthCookies } from "../utils/steedos-auth";
|
|
13
|
+
import { getObject } from "@steedos/objectql";
|
|
14
|
+
import * as requestIp from "request-ip";
|
|
15
|
+
import { getUserAgent } from "../utils/get-user-agent";
|
|
16
|
+
import isMobile from "ismobilejs";
|
|
17
|
+
import { getSteedosSchema } from "@steedos/objectql";
|
|
18
|
+
export const logout =
|
|
19
|
+
(accountsServer: AccountsServer) =>
|
|
20
|
+
async (req: express.Request, res: express.Response) => {
|
|
21
|
+
let authToken =
|
|
22
|
+
get(req.cookies, "X-Auth-Token") ||
|
|
23
|
+
get(req.headers, "Authorization") ||
|
|
24
|
+
get(req.headers, "authorization");
|
|
27
25
|
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
authToken = authToken && authToken.replace("Bearer ", "token");
|
|
27
|
+
authToken =
|
|
28
|
+
authToken && authToken.split(",").length > 1
|
|
29
|
+
? authToken.split(",")[0]
|
|
30
|
+
: authToken;
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
32
|
+
clearAuthCookies(req, res);
|
|
33
|
+
let session = null;
|
|
34
|
+
try {
|
|
35
|
+
session = await accountsServer.logout(authToken);
|
|
36
|
+
} catch (err) {
|
|
37
|
+
//sendError(res, err);
|
|
38
|
+
} finally {
|
|
39
|
+
let userAgent = getUserAgent(req) || "";
|
|
40
|
+
const ip = requestIp.getClientIp(req);
|
|
41
|
+
let status = "success";
|
|
42
|
+
let message = "";
|
|
43
|
+
let is_phone = false;
|
|
44
|
+
let is_tablet = false;
|
|
45
|
+
if (userAgent) {
|
|
46
|
+
try {
|
|
47
|
+
const { phone, tablet } = isMobile(userAgent);
|
|
48
|
+
is_phone = phone;
|
|
49
|
+
is_tablet = tablet;
|
|
50
|
+
} catch (Exception) {
|
|
51
|
+
console.log(`Exception`, Exception);
|
|
52
|
+
}
|
|
51
53
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
54
|
+
await getObject("operation_logs").insert({
|
|
55
|
+
name: "注销",
|
|
56
|
+
type: "logout",
|
|
57
|
+
remote_user: session?.userId,
|
|
58
|
+
remote_addr: ip,
|
|
59
|
+
http_user_agent: userAgent,
|
|
60
|
+
is_mobile: is_phone,
|
|
61
|
+
is_tablet,
|
|
62
|
+
object: "users",
|
|
63
|
+
status: status,
|
|
64
|
+
create: new Date(),
|
|
65
|
+
space: session?.space,
|
|
66
|
+
message: message,
|
|
67
|
+
data: JSON.stringify({
|
|
68
|
+
authToken: authToken,
|
|
69
|
+
session: session,
|
|
70
|
+
}),
|
|
71
|
+
related_to: {
|
|
72
|
+
o: "users",
|
|
73
|
+
ids: [session?.userId],
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
if (authToken) {
|
|
77
|
+
const broker = getSteedosSchema().broker;
|
|
78
|
+
broker.broadcast("$user.logout", {
|
|
79
|
+
authToken: authToken,
|
|
80
|
+
});
|
|
73
81
|
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
broker.broadcast("$user.logout", {
|
|
78
|
-
authToken: authToken
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
res.json(null);
|
|
82
|
-
};
|
|
82
|
+
}
|
|
83
|
+
res.json(null);
|
|
84
|
+
};
|