@volcanicminds/backend 2.0.0 → 2.0.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 +17 -0
- package/dist/lib/api/users/controller/user.js +41 -14
- package/dist/lib/api/users/controller/user.js.map +1 -1
- package/dist/lib/api/users/routes.js +27 -9
- package/dist/lib/api/users/routes.js.map +1 -1
- package/dist/lib/config/general.js +1 -0
- package/dist/lib/config/general.js.map +1 -1
- package/dist/lib/loader/general.js +1 -0
- package/dist/lib/loader/general.js.map +1 -1
- package/dist/lib/schemas/user.js +9 -1
- package/dist/lib/schemas/user.js.map +1 -1
- package/dist/package-lock.json +16 -38
- package/dist/package.json +1 -1
- package/lib/api/users/controller/user.ts +35 -13
- package/lib/api/users/routes.ts +27 -9
- package/lib/config/general.ts +1 -0
- package/lib/loader/general.ts +1 -0
- package/lib/schemas/user.ts +9 -0
- package/package.json +1 -1
- package/types/global.d.ts +1 -0
package/README.md
CHANGED
|
@@ -680,6 +680,23 @@ module.exports = {
|
|
|
680
680
|
}
|
|
681
681
|
```
|
|
682
682
|
|
|
683
|
+
## Disable embedded authorization
|
|
684
|
+
|
|
685
|
+
Out-of-the-box, the framework automatically secures all routes by checking for a valid (Bearer) JWT token if roles are defined for that route. However, if you want to disable this automatic authorization check and handle it manually within your controllers or middleware, you can do so by setting the `embedded_auth` option to `false`.
|
|
686
|
+
|
|
687
|
+
```ts
|
|
688
|
+
// src/config/general.ts
|
|
689
|
+
'use strict'
|
|
690
|
+
|
|
691
|
+
module.exports = {
|
|
692
|
+
name: 'general',
|
|
693
|
+
enable: true,
|
|
694
|
+
options: {
|
|
695
|
+
embedded_auth: false
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
```
|
|
699
|
+
|
|
683
700
|
## Job Scheduler
|
|
684
701
|
|
|
685
702
|
It's possible to add a job scheduler. For more information, go to [Fastify Schedule](https://github.com/fastify/fastify-schedule). To enable this feature, it's necessary to add or change the property `scheduler` to `true` (the default is `false`).
|
|
@@ -20,8 +20,6 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
return t;
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.currentUser = currentUser;
|
|
24
|
-
exports.isAdmin = isAdmin;
|
|
25
23
|
exports.getRoles = getRoles;
|
|
26
24
|
exports.count = count;
|
|
27
25
|
exports.find = find;
|
|
@@ -29,17 +27,14 @@ exports.findOne = findOne;
|
|
|
29
27
|
exports.create = create;
|
|
30
28
|
exports.update = update;
|
|
31
29
|
exports.remove = remove;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
function isAdmin(req, reply) {
|
|
37
|
-
const user = req.user;
|
|
38
|
-
reply.send({ isAdmin: (user === null || user === void 0 ? void 0 : user.getId()) && req.hasRole(roles.admin) });
|
|
39
|
-
}
|
|
30
|
+
exports.getCurrentUser = getCurrentUser;
|
|
31
|
+
exports.updateCurrentUser = updateCurrentUser;
|
|
32
|
+
exports.isAdmin = isAdmin;
|
|
40
33
|
function getRoles(req, reply) {
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const allRoles = Object.keys(roles).map((key) => roles[key]);
|
|
36
|
+
return reply.send(allRoles);
|
|
37
|
+
});
|
|
43
38
|
}
|
|
44
39
|
function count(req, reply) {
|
|
45
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -61,14 +56,23 @@ function findOne(req, reply) {
|
|
|
61
56
|
}
|
|
62
57
|
function create(req, reply) {
|
|
63
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
|
|
59
|
+
var _a;
|
|
60
|
+
if (!req.hasRole(roles.admin)) {
|
|
61
|
+
return reply.status(403).send(Error('Only admins can create users'));
|
|
62
|
+
}
|
|
63
|
+
const _b = req.data(), { id } = _b, data = __rest(_b, ["id"]);
|
|
64
|
+
if (data.roles && data.roles.includes(roles.admin)) {
|
|
65
|
+
if (!config.enable || ((_a = config.options) === null || _a === void 0 ? void 0 : _a.allow_multiple_admin) !== true) {
|
|
66
|
+
return reply.status(403).send(Error('Cannot assign admin role to a user'));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
65
69
|
const user = yield req.server['userManager'].createUser(data);
|
|
66
70
|
return user ? entity.User.save(user) : reply.status(400).send(Error('User not creatable'));
|
|
67
71
|
});
|
|
68
72
|
}
|
|
69
73
|
function update(req, reply) {
|
|
70
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
const _a = req.
|
|
75
|
+
const _a = req.data(), { id } = _a, userData = __rest(_a, ["id"]);
|
|
72
76
|
if (!id) {
|
|
73
77
|
return reply.status(400).send('Missing required id parameter');
|
|
74
78
|
}
|
|
@@ -84,4 +88,27 @@ function remove(req, reply) {
|
|
|
84
88
|
return yield req.server['userManager'].deleteUser(id);
|
|
85
89
|
});
|
|
86
90
|
}
|
|
91
|
+
function getCurrentUser(req, reply) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
const user = req.user;
|
|
94
|
+
return reply.send(user ? Object.assign(Object.assign({}, user), { roles: req.roles() }) : {});
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function updateCurrentUser(req, reply) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const user = req.user;
|
|
100
|
+
const id = user === null || user === void 0 ? void 0 : user.getId();
|
|
101
|
+
if (!id) {
|
|
102
|
+
return reply.status(403).send('Cannot update current user');
|
|
103
|
+
}
|
|
104
|
+
const _a = req.data(), { id: _id } = _a, userData = __rest(_a, ["id"]);
|
|
105
|
+
return yield req.server['userManager'].updateUserById(id, userData);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function isAdmin(req, reply) {
|
|
109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
const user = req.user;
|
|
111
|
+
return reply.send({ isAdmin: (user === null || user === void 0 ? void 0 : user.getId()) && req.hasRole(roles.admin) });
|
|
112
|
+
});
|
|
113
|
+
}
|
|
87
114
|
//# sourceMappingURL=user.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../../../../lib/api/users/controller/user.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAGA,
|
|
1
|
+
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../../../../lib/api/users/controller/user.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAGA,4BAGC;AAED,sBAEC;AAED,oBAGC;AAED,0BAIC;AAED,wBAeC;AAED,wBAOC;AAED,wBAMC;AAED,wCAGC;AAED,8CASC;AAED,0BAGC;AAzED,SAAsB,QAAQ,CAAC,GAAmB,EAAE,KAAmB;;QACrE,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;QAC5D,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC7B,CAAC;CAAA;AAED,SAAsB,KAAK,CAAC,GAAmB,EAAE,KAAmB;;QAClE,OAAO,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAA;IACzD,CAAC;CAAA;AAED,SAAsB,IAAI,CAAC,GAAmB,EAAE,KAAmB;;QACjE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAA;QAClF,OAAO,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACtE,C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AM,IAAI,GAAkC,GAAG,CAAC,IAAI,CAAA;QACpD,MAAM,EAAE,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,EAAE,CAAA;QACxB,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAA;QAC7D,CAAC;QAED,MAAM,KAA2B,GAAG,CAAC,IAAI,EAAE,EAArC,EAAE,EAAE,EAAE,GAAG,OAA4B,EAAvB,QAAQ,cAAtB,MAAwB,CAAa,CAAA;QAC3C,OAAO,MAAM,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,cAAc,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAA;IACrE,CAAC;CAAA;AAED,SAAsB,OAAO,CAAC,GAAmB,EAAE,KAAmB;;QACpE,MAAM,IAAI,GAAkC,GAAG,CAAC,IAAI,CAAA;QACpD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,EAAE,KAAI,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IAC3E,CAAC;CAAA"}
|
|
@@ -65,9 +65,9 @@ module.exports = {
|
|
|
65
65
|
{
|
|
66
66
|
method: 'GET',
|
|
67
67
|
path: '/:id',
|
|
68
|
-
roles: [],
|
|
68
|
+
roles: [roles.admin],
|
|
69
69
|
handler: 'user.findOne',
|
|
70
|
-
middlewares: [],
|
|
70
|
+
middlewares: ['global.isAuthenticated'],
|
|
71
71
|
config: {
|
|
72
72
|
title: 'Find user',
|
|
73
73
|
description: 'Get user by id',
|
|
@@ -83,9 +83,9 @@ module.exports = {
|
|
|
83
83
|
{
|
|
84
84
|
method: 'PUT',
|
|
85
85
|
path: '/:id',
|
|
86
|
-
roles: [],
|
|
86
|
+
roles: [roles.admin],
|
|
87
87
|
handler: 'user.update',
|
|
88
|
-
middlewares: [],
|
|
88
|
+
middlewares: ['global.isAuthenticated'],
|
|
89
89
|
config: {
|
|
90
90
|
title: 'Update user',
|
|
91
91
|
description: 'Updates a user by id',
|
|
@@ -102,9 +102,9 @@ module.exports = {
|
|
|
102
102
|
{
|
|
103
103
|
method: 'POST',
|
|
104
104
|
path: '/',
|
|
105
|
-
roles: [],
|
|
105
|
+
roles: [roles.admin],
|
|
106
106
|
handler: 'user.create',
|
|
107
|
-
middlewares: [],
|
|
107
|
+
middlewares: ['global.isAuthenticated'],
|
|
108
108
|
config: {
|
|
109
109
|
title: 'Create a user',
|
|
110
110
|
description: 'Creates a new user',
|
|
@@ -120,9 +120,9 @@ module.exports = {
|
|
|
120
120
|
{
|
|
121
121
|
method: 'DELETE',
|
|
122
122
|
path: '/:id',
|
|
123
|
-
roles: [],
|
|
123
|
+
roles: [roles.admin],
|
|
124
124
|
handler: 'user.remove',
|
|
125
|
-
middlewares: [],
|
|
125
|
+
middlewares: ['global.isAuthenticated'],
|
|
126
126
|
config: {
|
|
127
127
|
title: 'Delete user',
|
|
128
128
|
description: 'Deletes user by id',
|
|
@@ -139,7 +139,7 @@ module.exports = {
|
|
|
139
139
|
method: 'GET',
|
|
140
140
|
path: '/me',
|
|
141
141
|
roles: [],
|
|
142
|
-
handler: 'user.
|
|
142
|
+
handler: 'user.getCurrentUser',
|
|
143
143
|
middlewares: ['global.isAuthenticated'],
|
|
144
144
|
config: {
|
|
145
145
|
title: 'Get current user',
|
|
@@ -149,6 +149,24 @@ module.exports = {
|
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
},
|
|
152
|
+
{
|
|
153
|
+
method: 'PUT',
|
|
154
|
+
path: '/me',
|
|
155
|
+
roles: [],
|
|
156
|
+
handler: 'user.updateCurrentUser',
|
|
157
|
+
middlewares: ['global.isAuthenticated'],
|
|
158
|
+
config: {
|
|
159
|
+
title: 'Update current user',
|
|
160
|
+
description: 'Update current user',
|
|
161
|
+
body: { $ref: 'currentUserBodySchema#' },
|
|
162
|
+
response: {
|
|
163
|
+
200: {
|
|
164
|
+
description: 'Default response',
|
|
165
|
+
$ref: 'userSchema#'
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
},
|
|
152
170
|
{
|
|
153
171
|
method: 'GET',
|
|
154
172
|
path: '/is-admin',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../../../lib/api/users/routes.ts"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,GAAG;IACf,MAAM,EAAE;QACN,KAAK,EAAE,gBAAgB;QACvB,WAAW,EAAE,gBAAgB;QAC7B,UAAU,EAAE,YAAY;QACxB,IAAI,EAAE,CAAC,OAAO,CAAC;QACf,OAAO,EAAE,KAAK;KACf;IACD,MAAM,EAAE;QACN;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,GAAG;YACT,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC;YACpB,OAAO,EAAE,WAAW;YACpB,WAAW,EAAE,CAAC,wBAAwB,CAAC;YACvC,MAAM,EAAE;gBACN,KAAK,EAAE,YAAY;gBACnB,WAAW,EAAE,WAAW;gBACxB,KAAK,EAAE,EAAE,IAAI,EAAE,sBAAsB,EAAE;gBACvC,QAAQ,EAAE;oBACR,GAAG,EAAE;wBACH,WAAW,EAAE,kBAAkB;wBAC/B,IAAI,EAAE,OAAO;wBACb,KAAK,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE;qBAC/B;iBACF;aACF;SACF;QACD;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC;YACpB,OAAO,EAAE,YAAY;YACrB,WAAW,EAAE,CAAC,wBAAwB,CAAC;YACvC,MAAM,EAAE;gBACN,KAAK,EAAE,aAAa;gBACpB,WAAW,EAAE,aAAa;gBAC1B,QAAQ,EAAE;oBACR,GAAG,EAAE;wBACH,WAAW,EAAE,kBAAkB;wBAC/B,IAAI,EAAE,QAAQ;qBACf;iBACF;aACF;SACF;QACD;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC;YACpB,OAAO,EAAE,eAAe;YACxB,WAAW,EAAE,CAAC,wBAAwB,CAAC;YACvC,MAAM,EAAE;gBACN,KAAK,EAAE,eAAe;gBACtB,WAAW,EAAE,eAAe;gBAC5B,QAAQ,EAAE;oBACR,GAAG,EAAE;wBACH,WAAW,EAAE,kBAAkB;wBAC/B,IAAI,EAAE,OAAO;wBACb,KAAK,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE;qBAC/B;iBACF;aACF;SACF;QACD;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../../../lib/api/users/routes.ts"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,GAAG;IACf,MAAM,EAAE;QACN,KAAK,EAAE,gBAAgB;QACvB,WAAW,EAAE,gBAAgB;QAC7B,UAAU,EAAE,YAAY;QACxB,IAAI,EAAE,CAAC,OAAO,CAAC;QACf,OAAO,EAAE,KAAK;KACf;IACD,MAAM,EAAE;QACN;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,GAAG;YACT,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC;YACpB,OAAO,EAAE,WAAW;YACpB,WAAW,EAAE,CAAC,wBAAwB,CAAC;YACvC,MAAM,EAAE;gBACN,KAAK,EAAE,YAAY;gBACnB,WAAW,EAAE,WAAW;gBACxB,KAAK,EAAE,EAAE,IAAI,EAAE,sBAAsB,EAAE;gBACvC,QAAQ,EAAE;oBACR,GAAG,EAAE;wBACH,WAAW,EAAE,kBAAkB;wBAC/B,IAAI,EAAE,OAAO;wBACb,KAAK,EAAE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ACb,IAAI,EAAE,KAAK;YACX,KAAK,EAAE,EAAE;YACT,OAAO,EAAE,qBAAqB;YAC9B,WAAW,EAAE,CAAC,wBAAwB,CAAC;YACvC,MAAM,EAAE;gBACN,KAAK,EAAE,kBAAkB;gBACzB,WAAW,EAAE,kBAAkB;gBAC/B,QAAQ,EAAE;oBACR,GAAG,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE;iBAC7B;aACF;SACF;QACD;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,KAAK;YACX,KAAK,EAAE,EAAE;YACT,OAAO,EAAE,wBAAwB;YACjC,WAAW,EAAE,CAAC,wBAAwB,CAAC;YACvC,MAAM,EAAE;gBACN,KAAK,EAAE,qBAAqB;gBAC5B,WAAW,EAAE,qBAAqB;gBAClC,IAAI,EAAE,EAAE,IAAI,EAAE,wBAAwB,EAAE;gBACxC,QAAQ,EAAE;oBACR,GAAG,EAAE;wBACH,WAAW,EAAE,kBAAkB;wBAC/B,IAAI,EAAE,aAAa;qBACpB;iBACF;aACF;SACF;QACD;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,EAAE;YACT,OAAO,EAAE,cAAc;YACvB,WAAW,EAAE,CAAC,wBAAwB,CAAC;YACvC,MAAM,EAAE;gBACN,KAAK,EAAE,sBAAsB;gBAC7B,WAAW,EAAE,uCAAuC;gBACpD,QAAQ,EAAE;oBACR,GAAG,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE;iBAChC;aACF;SACF;KACF;CACF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"general.js","sourceRoot":"","sources":["../../../lib/config/general.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,MAAM,CAAC,OAAO,GAAG;IACf,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE;QACP,0BAA0B,EAAE,KAAK;QACjC,SAAS,EAAE,KAAK;QAChB,aAAa,EAAE,IAAI;KACpB;CACF,CAAA"}
|
|
1
|
+
{"version":3,"file":"general.js","sourceRoot":"","sources":["../../../lib/config/general.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,MAAM,CAAC,OAAO,GAAG;IACf,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE;QACP,oBAAoB,EAAE,KAAK;QAC3B,0BAA0B,EAAE,KAAK;QACjC,SAAS,EAAE,KAAK;QAChB,aAAa,EAAE,IAAI;KACpB;CACF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"general.js","sourceRoot":"","sources":["../../../lib/loader/general.ts"],"names":[],"mappings":";;AAIA,
|
|
1
|
+
{"version":3,"file":"general.js","sourceRoot":"","sources":["../../../lib/loader/general.ts"],"names":[],"mappings":";;AAIA,oBA8BC;AAjCD,uCAAgD;AAChD,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAE5B,SAAgB,IAAI;IAClB,MAAM,aAAa,GAAkB;QACnC,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE;YACP,oBAAoB,EAAE,KAAK;YAC3B,0BAA0B,EAAE,KAAK;YACjC,SAAS,EAAE,KAAK;YAChB,aAAa,EAAE,IAAI;SACpB;KACF,CAAA;IAED,MAAM,QAAQ,GAAG,IAAA,wBAAiB,EAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAA;IAC7G,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,cAAc,GAAG,OAAO,CAAC,CAAA;QAC5C,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAS,EAAE,EAAE;YACvC,MAAM,MAAM,GAAkB,OAAO,CAAC,CAAC,CAAC,CAAA;YAExC,IAAI,MAAM,CAAC,IAAI,KAAK,aAAa,CAAC,IAAI,EAAE,CAAC;gBACvC,aAAa,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;gBACpC,aAAa,CAAC,OAAO,mCAChB,aAAa,CAAC,OAAO,GACrB,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,CAC1B,CAAA;YACH,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAA;IAClD,OAAO,aAAa,CAAA;AACtB,CAAC"}
|
package/dist/lib/schemas/user.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.roleSchema = exports.isAdminSchema = exports.userSchema = exports.userBodySchema = void 0;
|
|
3
|
+
exports.roleSchema = exports.isAdminSchema = exports.userSchema = exports.userBodySchema = exports.currentUserBodySchema = void 0;
|
|
4
|
+
exports.currentUserBodySchema = {
|
|
5
|
+
$id: 'currentUserBodySchema',
|
|
6
|
+
type: 'object',
|
|
7
|
+
nullable: true,
|
|
8
|
+
properties: {
|
|
9
|
+
username: { type: 'string' }
|
|
10
|
+
}
|
|
11
|
+
};
|
|
4
12
|
exports.userBodySchema = {
|
|
5
13
|
$id: 'userBodySchema',
|
|
6
14
|
type: 'object',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../../lib/schemas/user.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG;IAC5B,GAAG,EAAE,gBAAgB;IACrB,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE;QACV,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC5B,KAAK,E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QAAQ,EAAE;QACxB,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACxB,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KAChC;CACF,CAAA"}
|
package/dist/package-lock.json
CHANGED
|
@@ -404,9 +404,9 @@
|
|
|
404
404
|
"license": "MIT"
|
|
405
405
|
},
|
|
406
406
|
"node_modules/@fastify/compress": {
|
|
407
|
-
"version": "8.
|
|
408
|
-
"resolved": "https://registry.npmjs.org/@fastify/compress/-/compress-8.
|
|
409
|
-
"integrity": "sha512-
|
|
407
|
+
"version": "8.3.0",
|
|
408
|
+
"resolved": "https://registry.npmjs.org/@fastify/compress/-/compress-8.3.0.tgz",
|
|
409
|
+
"integrity": "sha512-zYp6SCa7nJMxAse8+TXWNF0l0xV9K9GeMFwdr0aESAKfCEGo7N96b5vjFDFEz/pg8eyo1Am1B249UX79mS3x9A==",
|
|
410
410
|
"funding": [
|
|
411
411
|
{
|
|
412
412
|
"type": "github",
|
|
@@ -712,9 +712,9 @@
|
|
|
712
712
|
}
|
|
713
713
|
},
|
|
714
714
|
"node_modules/@fastify/swagger": {
|
|
715
|
-
"version": "9.
|
|
716
|
-
"resolved": "https://registry.npmjs.org/@fastify/swagger/-/swagger-9.
|
|
717
|
-
"integrity": "sha512-
|
|
715
|
+
"version": "9.6.0",
|
|
716
|
+
"resolved": "https://registry.npmjs.org/@fastify/swagger/-/swagger-9.6.0.tgz",
|
|
717
|
+
"integrity": "sha512-qYsQtaWgcVTh7V9OVnbtzpo7hHXS01utWeahs43XETgTTF+iYq7u8NKNZbuoLxj+IsluZ2vjWsQLTFOnWiuCbg==",
|
|
718
718
|
"funding": [
|
|
719
719
|
{
|
|
720
720
|
"type": "github",
|
|
@@ -3443,9 +3443,9 @@
|
|
|
3443
3443
|
}
|
|
3444
3444
|
},
|
|
3445
3445
|
"node_modules/fastify": {
|
|
3446
|
-
"version": "5.6.
|
|
3447
|
-
"resolved": "https://registry.npmjs.org/fastify/-/fastify-5.6.
|
|
3448
|
-
"integrity": "sha512-
|
|
3446
|
+
"version": "5.6.2",
|
|
3447
|
+
"resolved": "https://registry.npmjs.org/fastify/-/fastify-5.6.2.tgz",
|
|
3448
|
+
"integrity": "sha512-dPugdGnsvYkBlENLhCgX8yhyGCsCPrpA8lFWbTNU428l+YOnLgYHR69hzV8HWPC79n536EqzqQtvhtdaCE0dKg==",
|
|
3449
3449
|
"funding": [
|
|
3450
3450
|
{
|
|
3451
3451
|
"type": "github",
|
|
@@ -3468,7 +3468,7 @@
|
|
|
3468
3468
|
"fast-json-stringify": "^6.0.0",
|
|
3469
3469
|
"find-my-way": "^9.0.0",
|
|
3470
3470
|
"light-my-request": "^6.0.0",
|
|
3471
|
-
"pino": "^
|
|
3471
|
+
"pino": "^10.1.0",
|
|
3472
3472
|
"process-warning": "^5.0.0",
|
|
3473
3473
|
"rfdc": "^1.3.1",
|
|
3474
3474
|
"secure-json-parse": "^4.0.0",
|
|
@@ -3515,28 +3515,6 @@
|
|
|
3515
3515
|
"integrity": "sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw==",
|
|
3516
3516
|
"license": "BSD-3-Clause"
|
|
3517
3517
|
},
|
|
3518
|
-
"node_modules/fastify/node_modules/pino": {
|
|
3519
|
-
"version": "9.14.0",
|
|
3520
|
-
"resolved": "https://registry.npmjs.org/pino/-/pino-9.14.0.tgz",
|
|
3521
|
-
"integrity": "sha512-8OEwKp5juEvb/MjpIc4hjqfgCNysrS94RIOMXYvpYCdm/jglrKEiAYmiumbmGhCvs+IcInsphYDFwqrjr7398w==",
|
|
3522
|
-
"license": "MIT",
|
|
3523
|
-
"dependencies": {
|
|
3524
|
-
"@pinojs/redact": "^0.4.0",
|
|
3525
|
-
"atomic-sleep": "^1.0.0",
|
|
3526
|
-
"on-exit-leak-free": "^2.1.0",
|
|
3527
|
-
"pino-abstract-transport": "^2.0.0",
|
|
3528
|
-
"pino-std-serializers": "^7.0.0",
|
|
3529
|
-
"process-warning": "^5.0.0",
|
|
3530
|
-
"quick-format-unescaped": "^4.0.3",
|
|
3531
|
-
"real-require": "^0.2.0",
|
|
3532
|
-
"safe-stable-stringify": "^2.3.1",
|
|
3533
|
-
"sonic-boom": "^4.0.1",
|
|
3534
|
-
"thread-stream": "^3.0.0"
|
|
3535
|
-
},
|
|
3536
|
-
"bin": {
|
|
3537
|
-
"pino": "bin.js"
|
|
3538
|
-
}
|
|
3539
|
-
},
|
|
3540
3518
|
"node_modules/fastparallel": {
|
|
3541
3519
|
"version": "2.4.1",
|
|
3542
3520
|
"resolved": "https://registry.npmjs.org/fastparallel/-/fastparallel-2.4.1.tgz",
|
|
@@ -4608,9 +4586,9 @@
|
|
|
4608
4586
|
}
|
|
4609
4587
|
},
|
|
4610
4588
|
"node_modules/ip-address": {
|
|
4611
|
-
"version": "10.0
|
|
4612
|
-
"resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.0.
|
|
4613
|
-
"integrity": "sha512-
|
|
4589
|
+
"version": "10.1.0",
|
|
4590
|
+
"resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.1.0.tgz",
|
|
4591
|
+
"integrity": "sha512-XXADHxXmvT9+CRxhXg56LJovE+bmWnEWB78LB83VZTprKTmaC5QfruXocxzTZ2Kl0DNwKuBdlIhjL8LeY8Sf8Q==",
|
|
4614
4592
|
"dev": true,
|
|
4615
4593
|
"license": "MIT",
|
|
4616
4594
|
"engines": {
|
|
@@ -7267,9 +7245,9 @@
|
|
|
7267
7245
|
"license": "MIT"
|
|
7268
7246
|
},
|
|
7269
7247
|
"node_modules/path-scurry": {
|
|
7270
|
-
"version": "2.0.
|
|
7271
|
-
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.
|
|
7272
|
-
"integrity": "sha512-
|
|
7248
|
+
"version": "2.0.1",
|
|
7249
|
+
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.1.tgz",
|
|
7250
|
+
"integrity": "sha512-oWyT4gICAu+kaA7QWk/jvCHWarMKNs6pXOGWKDTr7cw4IGcUbW+PeTfbaQiLGheFRpjo6O9J0PmyMfQPjH71oA==",
|
|
7273
7251
|
"license": "BlueOak-1.0.0",
|
|
7274
7252
|
"dependencies": {
|
|
7275
7253
|
"lru-cache": "^11.0.0",
|
package/dist/package.json
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
import { FastifyReply, FastifyRequest } from 'fastify'
|
|
2
2
|
import { AuthenticatedUser } from '../../../../types/global'
|
|
3
3
|
|
|
4
|
-
export function
|
|
5
|
-
const user: AuthenticatedUser | undefined = req.user
|
|
6
|
-
reply.send(user ? { ...user, roles: req.roles() } : {})
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function isAdmin(req: FastifyRequest, reply: FastifyReply) {
|
|
10
|
-
const user: AuthenticatedUser | undefined = req.user
|
|
11
|
-
reply.send({ isAdmin: user?.getId() && req.hasRole(roles.admin) })
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function getRoles(req: FastifyRequest, reply: FastifyReply) {
|
|
4
|
+
export async function getRoles(req: FastifyRequest, reply: FastifyReply) {
|
|
15
5
|
const allRoles = Object.keys(roles).map((key) => roles[key])
|
|
16
|
-
reply.send(allRoles)
|
|
6
|
+
return reply.send(allRoles)
|
|
17
7
|
}
|
|
18
8
|
|
|
19
9
|
export async function count(req: FastifyRequest, reply: FastifyReply) {
|
|
@@ -32,13 +22,24 @@ export async function findOne(req: FastifyRequest, reply: FastifyReply) {
|
|
|
32
22
|
}
|
|
33
23
|
|
|
34
24
|
export async function create(req: FastifyRequest, reply: FastifyReply) {
|
|
25
|
+
if (!req.hasRole(roles.admin)) {
|
|
26
|
+
return reply.status(403).send(Error('Only admins can create users'))
|
|
27
|
+
}
|
|
28
|
+
|
|
35
29
|
const { id, ...data } = req.data()
|
|
30
|
+
|
|
31
|
+
if (data.roles && data.roles.includes(roles.admin)) {
|
|
32
|
+
if (!config.enable || config.options?.allow_multiple_admin !== true) {
|
|
33
|
+
return reply.status(403).send(Error('Cannot assign admin role to a user'))
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
36
37
|
const user = await req.server['userManager'].createUser(data)
|
|
37
38
|
return user ? entity.User.save(user) : reply.status(400).send(Error('User not creatable'))
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
export async function update(req: FastifyRequest, reply: FastifyReply) {
|
|
41
|
-
const { id, ...userData } = req.
|
|
42
|
+
const { id, ...userData } = req.data()
|
|
42
43
|
if (!id) {
|
|
43
44
|
return reply.status(400).send('Missing required id parameter')
|
|
44
45
|
}
|
|
@@ -53,3 +54,24 @@ export async function remove(req: FastifyRequest, reply: FastifyReply) {
|
|
|
53
54
|
}
|
|
54
55
|
return await req.server['userManager'].deleteUser(id)
|
|
55
56
|
}
|
|
57
|
+
|
|
58
|
+
export async function getCurrentUser(req: FastifyRequest, reply: FastifyReply) {
|
|
59
|
+
const user: AuthenticatedUser | undefined = req.user
|
|
60
|
+
return reply.send(user ? { ...user, roles: req.roles() } : {})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export async function updateCurrentUser(req: FastifyRequest, reply: FastifyReply) {
|
|
64
|
+
const user: AuthenticatedUser | undefined = req.user
|
|
65
|
+
const id = user?.getId()
|
|
66
|
+
if (!id) {
|
|
67
|
+
return reply.status(403).send('Cannot update current user')
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const { id: _id, ...userData } = req.data()
|
|
71
|
+
return await req.server['userManager'].updateUserById(id, userData)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export async function isAdmin(req: FastifyRequest, reply: FastifyReply) {
|
|
75
|
+
const user: AuthenticatedUser | undefined = req.user
|
|
76
|
+
return reply.send({ isAdmin: user?.getId() && req.hasRole(roles.admin) })
|
|
77
|
+
}
|
package/lib/api/users/routes.ts
CHANGED
|
@@ -64,9 +64,9 @@ module.exports = {
|
|
|
64
64
|
{
|
|
65
65
|
method: 'GET',
|
|
66
66
|
path: '/:id',
|
|
67
|
-
roles: [],
|
|
67
|
+
roles: [roles.admin],
|
|
68
68
|
handler: 'user.findOne',
|
|
69
|
-
middlewares: [],
|
|
69
|
+
middlewares: ['global.isAuthenticated'],
|
|
70
70
|
config: {
|
|
71
71
|
title: 'Find user',
|
|
72
72
|
description: 'Get user by id',
|
|
@@ -82,9 +82,9 @@ module.exports = {
|
|
|
82
82
|
{
|
|
83
83
|
method: 'PUT',
|
|
84
84
|
path: '/:id',
|
|
85
|
-
roles: [],
|
|
85
|
+
roles: [roles.admin],
|
|
86
86
|
handler: 'user.update',
|
|
87
|
-
middlewares: [],
|
|
87
|
+
middlewares: ['global.isAuthenticated'],
|
|
88
88
|
config: {
|
|
89
89
|
title: 'Update user',
|
|
90
90
|
description: 'Updates a user by id',
|
|
@@ -101,9 +101,9 @@ module.exports = {
|
|
|
101
101
|
{
|
|
102
102
|
method: 'POST',
|
|
103
103
|
path: '/',
|
|
104
|
-
roles: [],
|
|
104
|
+
roles: [roles.admin],
|
|
105
105
|
handler: 'user.create',
|
|
106
|
-
middlewares: [],
|
|
106
|
+
middlewares: ['global.isAuthenticated'],
|
|
107
107
|
config: {
|
|
108
108
|
title: 'Create a user',
|
|
109
109
|
description: 'Creates a new user',
|
|
@@ -119,9 +119,9 @@ module.exports = {
|
|
|
119
119
|
{
|
|
120
120
|
method: 'DELETE',
|
|
121
121
|
path: '/:id',
|
|
122
|
-
roles: [],
|
|
122
|
+
roles: [roles.admin],
|
|
123
123
|
handler: 'user.remove',
|
|
124
|
-
middlewares: [],
|
|
124
|
+
middlewares: ['global.isAuthenticated'],
|
|
125
125
|
config: {
|
|
126
126
|
title: 'Delete user',
|
|
127
127
|
description: 'Deletes user by id',
|
|
@@ -138,7 +138,7 @@ module.exports = {
|
|
|
138
138
|
method: 'GET',
|
|
139
139
|
path: '/me',
|
|
140
140
|
roles: [],
|
|
141
|
-
handler: 'user.
|
|
141
|
+
handler: 'user.getCurrentUser',
|
|
142
142
|
middlewares: ['global.isAuthenticated'],
|
|
143
143
|
config: {
|
|
144
144
|
title: 'Get current user',
|
|
@@ -148,6 +148,24 @@ module.exports = {
|
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
},
|
|
151
|
+
{
|
|
152
|
+
method: 'PUT',
|
|
153
|
+
path: '/me',
|
|
154
|
+
roles: [],
|
|
155
|
+
handler: 'user.updateCurrentUser',
|
|
156
|
+
middlewares: ['global.isAuthenticated'],
|
|
157
|
+
config: {
|
|
158
|
+
title: 'Update current user',
|
|
159
|
+
description: 'Update current user',
|
|
160
|
+
body: { $ref: 'currentUserBodySchema#' },
|
|
161
|
+
response: {
|
|
162
|
+
200: {
|
|
163
|
+
description: 'Default response',
|
|
164
|
+
$ref: 'userSchema#'
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
},
|
|
151
169
|
{
|
|
152
170
|
method: 'GET',
|
|
153
171
|
path: '/is-admin',
|
package/lib/config/general.ts
CHANGED
package/lib/loader/general.ts
CHANGED
package/lib/schemas/user.ts
CHANGED
package/package.json
CHANGED