@kne/fastify-account 1.0.0-alpha.9 → 2.0.0-alpha.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/README.md +6 -2046
- package/index.js +34 -21
- package/libs/controllers/account.js +246 -173
- package/libs/controllers/admin-user.js +110 -0
- package/libs/controllers/admin.js +55 -146
- package/libs/controllers/user.js +7 -24
- package/libs/models/example._js +13 -0
- package/libs/models/user-account.js +13 -32
- package/libs/models/user.js +37 -36
- package/libs/models/verification-code.js +16 -21
- package/libs/services/account.js +124 -149
- package/libs/services/admin.js +21 -73
- package/libs/services/user.js +52 -58
- package/package.json +24 -28
- package/libs/controllers/adminPermission.js +0 -237
- package/libs/controllers/adminRole.js +0 -146
- package/libs/controllers/adminTenant.js +0 -464
- package/libs/controllers/tenant.js +0 -34
- package/libs/models/admin-role.js +0 -15
- package/libs/models/application.js +0 -42
- package/libs/models/login-log.js +0 -11
- package/libs/models/permission.js +0 -51
- package/libs/models/tenant-application.js +0 -26
- package/libs/models/tenant-org.js +0 -26
- package/libs/models/tenant-permission.js +0 -26
- package/libs/models/tenant-role-application.js +0 -37
- package/libs/models/tenant-role-permission.js +0 -34
- package/libs/models/tenant-role.js +0 -23
- package/libs/models/tenant-share-group-permission.js +0 -18
- package/libs/models/tenant-share-group.js +0 -18
- package/libs/models/tenant-source-user-share-group.js +0 -18
- package/libs/models/tenant-token.js +0 -30
- package/libs/models/tenant-user-org.js +0 -23
- package/libs/models/tenant-user-role.js +0 -23
- package/libs/models/tenant-user-share-group.js +0 -18
- package/libs/models/tenant-user.js +0 -75
- package/libs/models/tenant.js +0 -46
- package/libs/services/application.js +0 -151
- package/libs/services/permission.js +0 -367
- package/libs/services/tenant-invite.js +0 -62
- package/libs/services/tenant-org.js +0 -97
- package/libs/services/tenant-role.js +0 -108
- package/libs/services/tenant-user.js +0 -555
- package/libs/services/tenant.js +0 -132
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
const fp = require('fastify-plugin');
|
|
2
|
-
|
|
3
|
-
module.exports = fp(async (fastify, options) => {
|
|
4
|
-
const { authenticate, services } = fastify.account;
|
|
5
|
-
fastify.post(
|
|
6
|
-
`${options.prefix}/admin/addApplication`,
|
|
7
|
-
{
|
|
8
|
-
onRequest: [authenticate.user, authenticate.admin],
|
|
9
|
-
schema: {
|
|
10
|
-
body: {
|
|
11
|
-
type: 'object',
|
|
12
|
-
required: ['name', 'code'],
|
|
13
|
-
properties: {
|
|
14
|
-
name: { type: 'string' },
|
|
15
|
-
url: { type: 'string' },
|
|
16
|
-
avatar: { type: 'string' },
|
|
17
|
-
code: { type: 'string' },
|
|
18
|
-
description: { type: 'string' }
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
async request => {
|
|
24
|
-
await services.application.addApplication(request.body);
|
|
25
|
-
return {};
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
fastify.post(
|
|
30
|
-
`${options.prefix}/admin/saveApplication`,
|
|
31
|
-
{
|
|
32
|
-
onRequest: [authenticate.user, authenticate.admin],
|
|
33
|
-
schema: {
|
|
34
|
-
body: {
|
|
35
|
-
type: 'object',
|
|
36
|
-
required: ['id', 'name', 'code'],
|
|
37
|
-
properties: {
|
|
38
|
-
id: { type: 'string' },
|
|
39
|
-
url: { type: 'string' },
|
|
40
|
-
name: { type: 'string' },
|
|
41
|
-
avatar: { type: 'string' },
|
|
42
|
-
code: { type: 'string' },
|
|
43
|
-
description: { type: 'string' }
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
async request => {
|
|
49
|
-
await services.application.saveApplication(request.body);
|
|
50
|
-
return {};
|
|
51
|
-
}
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
fastify.post(
|
|
55
|
-
`${options.prefix}/admin/deleteApplication`,
|
|
56
|
-
{
|
|
57
|
-
onRequest: [authenticate.user, authenticate.admin],
|
|
58
|
-
schema: {
|
|
59
|
-
body: {
|
|
60
|
-
type: 'object',
|
|
61
|
-
required: ['id'],
|
|
62
|
-
properties: {
|
|
63
|
-
id: { type: 'string' }
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
async request => {
|
|
69
|
-
const { id } = request.body;
|
|
70
|
-
await services.application.deleteApplication({ id });
|
|
71
|
-
return {};
|
|
72
|
-
}
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
fastify.get(
|
|
76
|
-
`${options.prefix}/admin/getApplicationList`,
|
|
77
|
-
{
|
|
78
|
-
onRequest: [authenticate.user, authenticate.admin],
|
|
79
|
-
schema: {
|
|
80
|
-
query: {
|
|
81
|
-
type: 'object',
|
|
82
|
-
properties: {
|
|
83
|
-
tenantId: { type: 'string' }
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
async request => {
|
|
89
|
-
const { tenantId } = request.query;
|
|
90
|
-
return await services.application.getApplicationList({ tenantId });
|
|
91
|
-
}
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
fastify.post(
|
|
95
|
-
`${options.prefix}/admin/addPermission`,
|
|
96
|
-
{
|
|
97
|
-
onRequest: [authenticate.user, authenticate.admin],
|
|
98
|
-
schema: {
|
|
99
|
-
body: {
|
|
100
|
-
type: 'object',
|
|
101
|
-
required: ['applicationId', 'name', 'code'],
|
|
102
|
-
properties: {
|
|
103
|
-
applicationId: { type: 'string' },
|
|
104
|
-
name: { type: 'string' },
|
|
105
|
-
code: { type: 'string' },
|
|
106
|
-
type: { type: 'number' },
|
|
107
|
-
isModule: { type: 'number' },
|
|
108
|
-
isMust: { type: 'number' },
|
|
109
|
-
pid: { type: 'number' },
|
|
110
|
-
description: { type: 'string' }
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
async request => {
|
|
116
|
-
await services.permission.addPermission(request.body);
|
|
117
|
-
return {};
|
|
118
|
-
}
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
fastify.get(
|
|
122
|
-
`${options.prefix}/admin/getPermissionList`,
|
|
123
|
-
{
|
|
124
|
-
onRequest: [authenticate.user, authenticate.admin],
|
|
125
|
-
schema: {
|
|
126
|
-
query: {
|
|
127
|
-
type: 'object',
|
|
128
|
-
required: ['applicationId'],
|
|
129
|
-
properties: {
|
|
130
|
-
applicationId: { type: 'string' },
|
|
131
|
-
tenantId: { type: 'string' }
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
async request => {
|
|
137
|
-
const { applicationId, tenantId } = request.query;
|
|
138
|
-
return await services.permission.getPermissionList({ applicationId, tenantId });
|
|
139
|
-
}
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
fastify.post(
|
|
143
|
-
`${options.prefix}/admin/deletePermission`,
|
|
144
|
-
{
|
|
145
|
-
onRequest: [authenticate.user, authenticate.admin],
|
|
146
|
-
schema: {
|
|
147
|
-
body: {
|
|
148
|
-
type: 'object',
|
|
149
|
-
required: ['id'],
|
|
150
|
-
properties: {
|
|
151
|
-
id: { type: 'string' }
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
async request => {
|
|
157
|
-
const { id } = request.body;
|
|
158
|
-
|
|
159
|
-
await services.permission.deletePermission({ id });
|
|
160
|
-
|
|
161
|
-
return {};
|
|
162
|
-
}
|
|
163
|
-
);
|
|
164
|
-
|
|
165
|
-
fastify.post(
|
|
166
|
-
`${options.prefix}/admin/savePermission`,
|
|
167
|
-
{
|
|
168
|
-
onRequest: [authenticate.user, authenticate.admin],
|
|
169
|
-
schema: {
|
|
170
|
-
body: {
|
|
171
|
-
type: 'object',
|
|
172
|
-
required: ['id'],
|
|
173
|
-
properties: {
|
|
174
|
-
id: { type: 'string' },
|
|
175
|
-
name: { type: 'string' },
|
|
176
|
-
type: { type: 'number' },
|
|
177
|
-
isMust: { type: 'number' },
|
|
178
|
-
description: { type: 'string' }
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
async request => {
|
|
184
|
-
await services.permission.savePermission(request.body);
|
|
185
|
-
return {};
|
|
186
|
-
}
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
fastify.post(
|
|
190
|
-
`${options.prefix}/admin/saveTenantPermissionList`,
|
|
191
|
-
{
|
|
192
|
-
onRequest: [authenticate.user, authenticate.admin],
|
|
193
|
-
schema: {
|
|
194
|
-
body: {
|
|
195
|
-
type: 'object',
|
|
196
|
-
required: ['tenantId', 'applications', 'permissions'],
|
|
197
|
-
properties: {
|
|
198
|
-
tenantId: { type: 'string' },
|
|
199
|
-
applications: {
|
|
200
|
-
type: 'array',
|
|
201
|
-
items: { type: 'string' }
|
|
202
|
-
},
|
|
203
|
-
permissions: {
|
|
204
|
-
type: 'array',
|
|
205
|
-
items: { type: 'number' }
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
},
|
|
211
|
-
async request => {
|
|
212
|
-
await services.permission.saveTenantPermissionList(request.body);
|
|
213
|
-
|
|
214
|
-
return {};
|
|
215
|
-
}
|
|
216
|
-
);
|
|
217
|
-
|
|
218
|
-
fastify.get(
|
|
219
|
-
`${options.prefix}/admin/getTenantPermissionList`,
|
|
220
|
-
{
|
|
221
|
-
onRequest: [authenticate.user, authenticate.admin],
|
|
222
|
-
schema: {
|
|
223
|
-
query: {
|
|
224
|
-
type: 'object',
|
|
225
|
-
required: ['tenantId'],
|
|
226
|
-
properties: {
|
|
227
|
-
tenantId: { type: 'string' }
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
},
|
|
232
|
-
async request => {
|
|
233
|
-
const { tenantId } = request.query;
|
|
234
|
-
return await services.permission.getTenantPermissionList({ tenantId });
|
|
235
|
-
}
|
|
236
|
-
);
|
|
237
|
-
});
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
const fp = require('fastify-plugin');
|
|
2
|
-
|
|
3
|
-
module.exports = fp(async (fastify, options) => {
|
|
4
|
-
const { authenticate, services } = fastify.account;
|
|
5
|
-
fastify.get(
|
|
6
|
-
`${options.prefix}/admin/getRoleList`,
|
|
7
|
-
{
|
|
8
|
-
onRequest: [authenticate.user, authenticate.admin],
|
|
9
|
-
schema: {
|
|
10
|
-
query: {
|
|
11
|
-
type: 'object',
|
|
12
|
-
required: ['tenantId'],
|
|
13
|
-
properties: {
|
|
14
|
-
tenantId: { type: 'string' },
|
|
15
|
-
filter: {
|
|
16
|
-
type: 'object',
|
|
17
|
-
properties: {
|
|
18
|
-
type: { type: 'number' }
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
async request => {
|
|
26
|
-
const { filter, tenantId, perPage, currentPage } = Object.assign(
|
|
27
|
-
{
|
|
28
|
-
perPage: 20,
|
|
29
|
-
currentPage: 1,
|
|
30
|
-
filter: {}
|
|
31
|
-
},
|
|
32
|
-
request.query
|
|
33
|
-
);
|
|
34
|
-
return await services.tenantRole.getTenantRoleList({ tenantId, perPage, currentPage, filter });
|
|
35
|
-
}
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
fastify.post(
|
|
39
|
-
`${options.prefix}/admin/addRole`,
|
|
40
|
-
{
|
|
41
|
-
onRequest: [authenticate.user, authenticate.admin],
|
|
42
|
-
schema: {
|
|
43
|
-
body: {
|
|
44
|
-
type: 'object',
|
|
45
|
-
required: ['tenantId', 'name'],
|
|
46
|
-
properties: {
|
|
47
|
-
tenantId: { type: 'string' },
|
|
48
|
-
name: { type: 'string' },
|
|
49
|
-
description: { type: 'string' }
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
async request => {
|
|
55
|
-
const { tenantId, name, description } = request.body;
|
|
56
|
-
await services.tenantRole.addTenantRole({ tenantId, name, description });
|
|
57
|
-
|
|
58
|
-
return {};
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
fastify.post(
|
|
63
|
-
`${options.prefix}/admin/saveRole`,
|
|
64
|
-
{
|
|
65
|
-
onRequest: [authenticate.user, authenticate.admin],
|
|
66
|
-
schema: {
|
|
67
|
-
body: {
|
|
68
|
-
type: 'object',
|
|
69
|
-
required: ['name', 'id'],
|
|
70
|
-
properties: {
|
|
71
|
-
id: { type: 'number' },
|
|
72
|
-
name: { type: 'string' },
|
|
73
|
-
description: { type: 'string' }
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
async request => {
|
|
79
|
-
await services.tenantRole.saveTenantRole(request.body);
|
|
80
|
-
return {};
|
|
81
|
-
}
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
fastify.post(
|
|
85
|
-
`${options.prefix}/admin/removeRole`,
|
|
86
|
-
{
|
|
87
|
-
onRequest: [authenticate.user, authenticate.admin],
|
|
88
|
-
schema: {
|
|
89
|
-
body: {
|
|
90
|
-
type: 'object',
|
|
91
|
-
required: ['id'],
|
|
92
|
-
properties: {
|
|
93
|
-
id: { type: 'number' }
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
async request => {
|
|
99
|
-
const { id } = request.body;
|
|
100
|
-
await services.tenantRole.removeTenantRole({ id });
|
|
101
|
-
return {};
|
|
102
|
-
}
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
fastify.get(
|
|
106
|
-
`${options.prefix}/admin/getRolePermissionList`,
|
|
107
|
-
{
|
|
108
|
-
onRequest: [authenticate.user, authenticate.admin],
|
|
109
|
-
schema: {
|
|
110
|
-
query: {
|
|
111
|
-
type: 'object',
|
|
112
|
-
required: ['id'],
|
|
113
|
-
properties: {
|
|
114
|
-
id: { type: 'number' }
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
async request => {
|
|
120
|
-
const { id } = request.query;
|
|
121
|
-
return await services.permission.getRolePermissionList({ roleId: id });
|
|
122
|
-
}
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
fastify.post(
|
|
126
|
-
`${options.prefix}/admin/saveRolePermissionList`,
|
|
127
|
-
{
|
|
128
|
-
onRequest: [authenticate.user, authenticate.admin],
|
|
129
|
-
schema: {
|
|
130
|
-
roleId: { type: 'string' },
|
|
131
|
-
applications: {
|
|
132
|
-
type: 'array',
|
|
133
|
-
items: { type: 'string' }
|
|
134
|
-
},
|
|
135
|
-
permissions: {
|
|
136
|
-
type: 'array',
|
|
137
|
-
items: { type: 'number' }
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
async request => {
|
|
142
|
-
await services.permission.saveRolePermissionList(request.body);
|
|
143
|
-
return {};
|
|
144
|
-
}
|
|
145
|
-
);
|
|
146
|
-
});
|