nodefony 6.12.0 → 7.0.0-beta.2
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/CHANGELOG.md +2043 -1815
- package/README.md +2 -2
- package/autoloader.es6 +11 -9
- package/cli/builder/bundles/users-bundle/Resources/config/config.js +3 -7
- package/cli/builder/bundles/users-bundle/Resources/config/security.js +2 -9
- package/cli/builder/bundles/users-bundle/Resources/config/webpack.config.js +1 -3
- package/cli/builder/bundles/users-bundle/controller/api/graphql/graphqlController.js +15 -17
- package/cli/builder/bundles/users-bundle/controller/api/graphql/userResolver.js +121 -0
- package/cli/builder/bundles/users-bundle/controller/api/graphql/{userSchema.js → usertype.js} +26 -29
- package/cli/builder/bundles/users-bundle/controller/api/openapi/loginApiController.js +1 -2
- package/cli/builder/bundles/users-bundle/controller/api/openapi/restUserController.js +18 -15
- package/cli/builder/bundles/users-bundle/controller/usersController.js +11 -7
- package/cli/builder/bundles/users-bundle/package.json +18 -25
- package/cli/builder/bundles/users-bundle/services/usersService.js +180 -128
- package/cli/builder/microService/skeletons/package.json +23 -23
- package/cli/builder/project/skeletons/README.md +2 -2
- package/cli/builder/project/skeletons/package.json.skeleton +6 -6
- package/cli/builder/skeletons/config/nodefony/framework-bundle.js +5 -0
- package/cli/builder/skeletons/config/webpack.config.js +1 -1
- package/cli/builder/skeletons/package.json +17 -17
- package/cli/builder/vue/skeletons/vue.config.js +1 -1
- package/cli/start.js +2 -1
- package/cli.es6 +31 -19
- package/finder/fileResult.es6 +7 -2
- package/finder/finder2.es6 +2 -2
- package/kernel/api/graphqlApi.es6 +54 -7
- package/kernel/api/jsonApi.es6 +8 -2
- package/kernel/bundle.es6 +15 -18
- package/kernel/commands/nodefonyCommand.es6 +7 -2
- package/kernel/injections/injections.es6 +5 -1
- package/kernel/kernel.es6 +348 -182
- package/kernel/kernelWatcher.es6 +3 -3
- package/kernel/security/secureArea.es6 +1 -1
- package/nodefony.es6 +109 -16
- package/package.json +41 -38
- package/result.es6 +1 -1
- package/cli/builder/bundles/users-bundle/Resources/graphiql/config.js +0 -5
- package/cli/builder/bundles/users-bundle/Resources/graphiql/graphiql.jsx +0 -96
- package/cli/builder/bundles/users-bundle/Resources/graphiql/index.css +0 -7
- package/cli/builder/bundles/users-bundle/Resources/swagger/config.js +0 -12
- package/cli/builder/bundles/users-bundle/Resources/swagger/swagger.css +0 -18
- package/cli/builder/bundles/users-bundle/Resources/swagger/swagger.js +0 -65
- package/cli/builder/bundles/users-bundle/Resources/views/documentation/base.html.twig +0 -37
- package/cli/builder/bundles/users-bundle/Resources/views/documentation/index.html.twig +0 -25
- package/cli/builder/bundles/users-bundle/Resources/views/documentation/navbar.html.twig +0 -12
- package/cli/builder/bundles/users-bundle/Resources/views/documentation/slides.html.twig +0 -37
- package/cli/builder/bundles/users-bundle/Resources/views/graphiql/index.html.twig +0 -40
- package/cli/builder/bundles/users-bundle/Resources/views/swagger/index.html.twig +0 -28
- package/cli/builder/bundles/users-bundle/controller/documentationController.js +0 -68
package/README.md
CHANGED
|
@@ -416,7 +416,7 @@ You can find certificate authority (ca) here:
|
|
|
416
416
|
#### Access to Secure App with URL : <https://localhost:5152>
|
|
417
417
|
#### Access to App with URL : <http://localhost:5151>
|
|
418
418
|
|
|
419
|
-
[](https://nodefony.net)
|
|
420
420
|
|
|
421
421
|
## <a name="configurations"></a>Framework Configurations
|
|
422
422
|
|
|
@@ -713,7 +713,7 @@ module.exports = webpackMerge(config, {
|
|
|
713
713
|
|
|
714
714
|
Access to monitoring route with URL : <http://localhost:5151/nodefony>
|
|
715
715
|
|
|
716
|
-
[](https://nodefony.net/nodefony)
|
|
717
717
|
|
|
718
718
|
Monitoring in progress !!!
|
|
719
719
|
|
package/autoloader.es6
CHANGED
|
@@ -2,10 +2,11 @@ const vm = require("vm");
|
|
|
2
2
|
const path = require("path");
|
|
3
3
|
const Module = require("module");
|
|
4
4
|
const fs = require('fs');
|
|
5
|
+
const pm2 = require('pm2');
|
|
6
|
+
//console.log(require.resolve("pm2"))
|
|
5
7
|
const Nodefony = require(path.resolve(__dirname, "nodefony.es6"));
|
|
6
8
|
|
|
7
9
|
module.exports = function () {
|
|
8
|
-
|
|
9
10
|
// Create Context copy library in context see load runInThisContext
|
|
10
11
|
const context = vm.createContext(this);
|
|
11
12
|
|
|
@@ -25,17 +26,16 @@ module.exports = function () {
|
|
|
25
26
|
//context.async = require('async');
|
|
26
27
|
//context.nodedomain = require('domain');
|
|
27
28
|
context.Promise = require('promise');
|
|
28
|
-
context.inquirer = require('inquirer');
|
|
29
|
+
//context.inquirer = require('inquirer');
|
|
29
30
|
context.clc = require('cli-color');
|
|
30
31
|
context.shell = require("shelljs");
|
|
31
32
|
context.twig = require("twig");
|
|
32
33
|
context.crypto = require("crypto");
|
|
33
34
|
context.BlueBird = require("bluebird");
|
|
34
|
-
context.pm2 =
|
|
35
|
+
context.pm2 = pm2;
|
|
35
36
|
//context.Rx = require("rxjs");
|
|
36
37
|
const nodefony = new Nodefony(context);
|
|
37
38
|
|
|
38
|
-
|
|
39
39
|
/**
|
|
40
40
|
* Nodefony autoloader
|
|
41
41
|
*
|
|
@@ -173,7 +173,7 @@ module.exports = function () {
|
|
|
173
173
|
delete Module._cache[filename];
|
|
174
174
|
}
|
|
175
175
|
console.error(e);
|
|
176
|
-
if(this.kernel){
|
|
176
|
+
if (this.kernel) {
|
|
177
177
|
this.kernel.terminate(1);
|
|
178
178
|
}
|
|
179
179
|
throw e;
|
|
@@ -234,10 +234,12 @@ module.exports = function () {
|
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
autoloadEach(ele) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
237
|
+
if (!ele.isDirectory()) {
|
|
238
|
+
let res = regJs.exec(ele.path)
|
|
239
|
+
if (res) {
|
|
240
|
+
this.load.call(this, ele.path);
|
|
241
|
+
this.log(ele.path, "DEBUG");
|
|
242
|
+
}
|
|
241
243
|
}
|
|
242
244
|
}
|
|
243
245
|
|
|
@@ -74,14 +74,10 @@ module.exports = {
|
|
|
74
74
|
},
|
|
75
75
|
jwt: {
|
|
76
76
|
token: {
|
|
77
|
-
expiresIn: 900
|
|
77
|
+
expiresIn: 900 // seconds
|
|
78
78
|
},
|
|
79
79
|
refreshToken: {
|
|
80
|
-
expiresIn: 3600
|
|
80
|
+
expiresIn: 3600 // seconds
|
|
81
81
|
}
|
|
82
|
-
}
|
|
83
|
-
swagger: require(path.resolve(__dirname, "..", "swagger", "config.js")),
|
|
84
|
-
|
|
85
|
-
graphiql: require(path.resolve(__dirname, "..", "graphiql", "config.js"))
|
|
86
|
-
|
|
82
|
+
}
|
|
87
83
|
};
|
|
@@ -39,14 +39,7 @@ module.exports = {
|
|
|
39
39
|
/**
|
|
40
40
|
* FIREWALL Authorization
|
|
41
41
|
*/
|
|
42
|
-
access_control: [
|
|
43
|
-
path: /^\/nodefony/,
|
|
44
|
-
roles: ["ROLE_MONITORING"],
|
|
45
|
-
requires_channel: "https",
|
|
46
|
-
/*allow_if: {
|
|
47
|
-
roles: ["ROLE_ADMIN", "ROLE_USER"]
|
|
48
|
-
}*/
|
|
49
|
-
}],
|
|
42
|
+
access_control: [],
|
|
50
43
|
|
|
51
44
|
firewalls: {
|
|
52
45
|
// SECURITY AREA <passport-local>
|
|
@@ -74,7 +67,7 @@ module.exports = {
|
|
|
74
67
|
usernameField: 'username',
|
|
75
68
|
passwordField: 'passwd'
|
|
76
69
|
},
|
|
77
|
-
stateless:
|
|
70
|
+
stateless: false,
|
|
78
71
|
redirectHttps: true,
|
|
79
72
|
crossDomain: cors
|
|
80
73
|
},
|
|
@@ -29,9 +29,7 @@ module.exports = merge(config, {
|
|
|
29
29
|
//context: context,
|
|
30
30
|
target: "web",
|
|
31
31
|
entry: {
|
|
32
|
-
users: ["./Resources/js/users.js"]
|
|
33
|
-
swagger: ["./Resources/swagger/swagger.js"],
|
|
34
|
-
graphiql: ["./Resources/graphiql/graphiql.jsx"]
|
|
32
|
+
users: ["./Resources/js/users.js"]
|
|
35
33
|
},
|
|
36
34
|
output: {
|
|
37
35
|
path: public,
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* @Route ("/api/graphql/users")
|
|
3
3
|
*
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
const userType = require(path.resolve(__dirname, "userType.js"));
|
|
6
|
+
const userResolver = require(path.resolve(__dirname, "userResolver.js"));
|
|
6
7
|
|
|
7
|
-
class graphqlController extends nodefony.Controller {
|
|
8
|
+
module.exports = class graphqlController extends nodefony.Controller {
|
|
8
9
|
|
|
9
10
|
constructor(container, context) {
|
|
10
11
|
super(container, context);
|
|
@@ -16,14 +17,14 @@ class graphqlController extends nodefony.Controller {
|
|
|
16
17
|
version: this.bundle.version,
|
|
17
18
|
description: "Nodefony Users graphql Api",
|
|
18
19
|
basePath: "/api/graphql/users",
|
|
19
|
-
schema:
|
|
20
|
+
schema: graphqlController.schema(this.context),
|
|
21
|
+
rootValue: this
|
|
20
22
|
}, this.context);
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
/**
|
|
24
26
|
* @Method ({"GET", "POST","OPTIONS"})
|
|
25
27
|
* @Route ( "*",name="api-user-graphql")
|
|
26
|
-
* @Firewall ({bypass:true})
|
|
27
28
|
*/
|
|
28
29
|
graphqlAction() {
|
|
29
30
|
try {
|
|
@@ -31,6 +32,7 @@ class graphqlController extends nodefony.Controller {
|
|
|
31
32
|
.then((data) => {
|
|
32
33
|
return this.api.render(data);
|
|
33
34
|
}).catch((e) => {
|
|
35
|
+
this.api.logger(this.query.query, "WARNING")
|
|
34
36
|
this.api.logger(e, "ERROR");
|
|
35
37
|
return this.api.renderError(e, 400);
|
|
36
38
|
});
|
|
@@ -39,22 +41,18 @@ class graphqlController extends nodefony.Controller {
|
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
static schema(context) {
|
|
45
|
+
return nodefony.api.Graphql.makeExecutableSchema({
|
|
46
|
+
typeDefs: graphqlController.types(context),
|
|
47
|
+
resolvers: graphqlController.resolvers(context)
|
|
48
|
+
});
|
|
46
49
|
}
|
|
47
50
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return res.rows ;
|
|
51
|
+
static types(context) {
|
|
52
|
+
return [userType];
|
|
51
53
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
let res = await this.usersService.create(field);
|
|
55
|
-
return res;
|
|
54
|
+
static resolvers(context) {
|
|
55
|
+
return [userResolver]
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
module.exports = graphqlController;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
Query: {
|
|
3
|
+
// provides all functions for each API endpoint
|
|
4
|
+
async user(obj, field, context, info) {
|
|
5
|
+
const user = context.getUser()
|
|
6
|
+
const usersService = context.get("users");
|
|
7
|
+
return await usersService.findOne(field.username, user);
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
async users(obj, field, context, info) {
|
|
11
|
+
const user = context.getUser()
|
|
12
|
+
const usersService = context.get("users");
|
|
13
|
+
let res = await usersService.find({}, {}, user);
|
|
14
|
+
return res.rows;
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
Mutation: {
|
|
18
|
+
async addUser(obj, field, context, info) {
|
|
19
|
+
const {
|
|
20
|
+
input
|
|
21
|
+
} = field;
|
|
22
|
+
const user = context.getUser()
|
|
23
|
+
const usersService = context.get("users");
|
|
24
|
+
let myuser = null;
|
|
25
|
+
let error = null;
|
|
26
|
+
if (!input.password || !input.confirm) {
|
|
27
|
+
error = new Error(`Password can't be empty`);
|
|
28
|
+
}
|
|
29
|
+
if (input.password !== input.confirm) {
|
|
30
|
+
error = new Error(`Bad confirm password`);
|
|
31
|
+
}
|
|
32
|
+
if (error) {
|
|
33
|
+
context.logger(error, "ERROR");
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
myuser = await usersService.create(input, user);
|
|
38
|
+
if (myuser) {
|
|
39
|
+
delete myuser.password;
|
|
40
|
+
delete myuser["2fa-token"];
|
|
41
|
+
return myuser
|
|
42
|
+
}
|
|
43
|
+
throw new nodefony.Error("user not create",400)
|
|
44
|
+
} catch (e) {
|
|
45
|
+
context.logger(e, "ERROR");
|
|
46
|
+
throw new nodefony.Error(e,400)
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
async updateUser(obj, field, context, info) {
|
|
51
|
+
const user = context.getUser()
|
|
52
|
+
const usersService = context.get("users");
|
|
53
|
+
const orm = context.kernel.getORM();
|
|
54
|
+
const {
|
|
55
|
+
input
|
|
56
|
+
} = field;
|
|
57
|
+
const username = input.username
|
|
58
|
+
return usersService.findOne(username, user)
|
|
59
|
+
.then(async (myuser) => {
|
|
60
|
+
if (myuser) {
|
|
61
|
+
if (input.password) {
|
|
62
|
+
let confirm = false
|
|
63
|
+
if (input.confirm) {
|
|
64
|
+
if (input.password !== input.confirm) {
|
|
65
|
+
throw new Error(`Bad confirm password`);
|
|
66
|
+
}
|
|
67
|
+
delete input.confirm;
|
|
68
|
+
confirm = true;
|
|
69
|
+
}
|
|
70
|
+
if (input["old-password"]) {
|
|
71
|
+
let encoder = orm.getNodefonyEntity("user").getEncoder();
|
|
72
|
+
let check = await encoder.isPasswordValid(input["old-password"], myuser.password);
|
|
73
|
+
if (!check) {
|
|
74
|
+
throw new Error(`User ${username} bad passport`);
|
|
75
|
+
}
|
|
76
|
+
delete input["old-password"];
|
|
77
|
+
confirm = true;
|
|
78
|
+
}
|
|
79
|
+
if (!confirm) {
|
|
80
|
+
throw new Error(`User ${username} no confirm passport`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return usersService.update(myuser, input, user)
|
|
84
|
+
.then(async (res) => {
|
|
85
|
+
let message = `Update User ${input.username} OK`;
|
|
86
|
+
context.log(message, "INFO");
|
|
87
|
+
if (context.session && myuser.username === user.username) {
|
|
88
|
+
if (input.username !== myuser.username) {
|
|
89
|
+
user.username = input.username;
|
|
90
|
+
}
|
|
91
|
+
if (context.locale !== input.lang) {
|
|
92
|
+
context.session.set("lang", input.lang);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
let newUser = await usersService.findOne(input.username, user);
|
|
96
|
+
delete newUser.password;
|
|
97
|
+
delete newUser["2fa-token"];
|
|
98
|
+
return newUser
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
throw new Error(`User ${username} not found`);
|
|
102
|
+
})
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
async deleteUser(obj, field, context, info){
|
|
106
|
+
const {
|
|
107
|
+
username
|
|
108
|
+
} = field;
|
|
109
|
+
const user = context.getUser()
|
|
110
|
+
const usersService = context.get("users");
|
|
111
|
+
return usersService.delete(username, user)
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
async deleteUsers(obj, field, context, info){
|
|
115
|
+
const {
|
|
116
|
+
users
|
|
117
|
+
} = field;
|
|
118
|
+
return []
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
package/cli/builder/bundles/users-bundle/controller/api/graphql/{userSchema.js → usertype.js}
RENAMED
|
@@ -1,29 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* user(username: "admin") {
|
|
4
|
-
* username
|
|
5
|
-
* surname
|
|
6
|
-
* name
|
|
7
|
-
* }
|
|
8
|
-
* users {
|
|
9
|
-
* username
|
|
10
|
-
* name
|
|
11
|
-
* surname
|
|
12
|
-
* updatedAt
|
|
13
|
-
* roles
|
|
14
|
-
* }
|
|
15
|
-
* }
|
|
16
|
-
*
|
|
17
|
-
* mutation addUser {
|
|
18
|
-
* addUser(username: "Jon", email: "Doe@foo.fr", password:"mypass") {
|
|
19
|
-
* username
|
|
20
|
-
* email
|
|
21
|
-
* name
|
|
22
|
-
* role s
|
|
23
|
-
* }
|
|
24
|
-
* }
|
|
25
|
-
*/
|
|
26
|
-
const schema = `
|
|
1
|
+
const type = `
|
|
2
|
+
|
|
27
3
|
scalar Date
|
|
28
4
|
scalar Url
|
|
29
5
|
scalar Array
|
|
@@ -46,6 +22,24 @@ const schema = `
|
|
|
46
22
|
roles : Array
|
|
47
23
|
}
|
|
48
24
|
|
|
25
|
+
input UserInput {
|
|
26
|
+
username: String!
|
|
27
|
+
surname: String
|
|
28
|
+
name: String
|
|
29
|
+
enabled: Boolean
|
|
30
|
+
password: String
|
|
31
|
+
confirm: String
|
|
32
|
+
userNonExpired: Boolean
|
|
33
|
+
credentialsNonExpired : Boolean
|
|
34
|
+
accountNonLocked: Boolean
|
|
35
|
+
email : String!
|
|
36
|
+
lang : String
|
|
37
|
+
gender: String
|
|
38
|
+
url : Url
|
|
39
|
+
image: String
|
|
40
|
+
roles : Array
|
|
41
|
+
}
|
|
42
|
+
|
|
49
43
|
# the schema allows the following query:
|
|
50
44
|
type Query {
|
|
51
45
|
user(username: String!): User
|
|
@@ -54,8 +48,11 @@ const schema = `
|
|
|
54
48
|
|
|
55
49
|
# this schema allows the following mutation:
|
|
56
50
|
type Mutation {
|
|
57
|
-
addUser(
|
|
51
|
+
addUser(input: UserInput!): User!
|
|
52
|
+
updateUser(username:String!, input: UserInput!): User!
|
|
53
|
+
deleteUser(username:String!): User!
|
|
54
|
+
deleteUsers(users:Array!): [User]!
|
|
58
55
|
}
|
|
59
|
-
|
|
56
|
+
`
|
|
60
57
|
|
|
61
|
-
module.exports =
|
|
58
|
+
module.exports = type
|
|
@@ -33,7 +33,6 @@ class loginApiController extends nodefony.Controller {
|
|
|
33
33
|
/**
|
|
34
34
|
* @Method ({"OPTIONS"})
|
|
35
35
|
* @Route ( "",name="api-login-options",)
|
|
36
|
-
* @Firewall ({bypass:true})
|
|
37
36
|
*/
|
|
38
37
|
optionsAction() {
|
|
39
38
|
try {
|
|
@@ -132,7 +131,7 @@ class loginApiController extends nodefony.Controller {
|
|
|
132
131
|
* "/refresh",
|
|
133
132
|
* name="api-login-jwt-refresh"
|
|
134
133
|
* )
|
|
135
|
-
*
|
|
134
|
+
* @Firewall ({bypass:true})
|
|
136
135
|
*/
|
|
137
136
|
async refreshAction() {
|
|
138
137
|
// get refreshToken from request
|
|
@@ -71,13 +71,14 @@ class restController extends nodefony.Controller {
|
|
|
71
71
|
*/
|
|
72
72
|
async getAction(username) {
|
|
73
73
|
let result = null;
|
|
74
|
+
const user = this.getUser();
|
|
74
75
|
try {
|
|
75
76
|
if (username) {
|
|
76
|
-
result = await this.usersService.findOne(username, this.query);
|
|
77
|
+
result = await this.usersService.findOne(username, this.query, user);
|
|
77
78
|
delete result.password;
|
|
78
79
|
delete result["2fa-token"];
|
|
79
80
|
} else {
|
|
80
|
-
result = await this.usersService.find(this.query.query, this.query);
|
|
81
|
+
result = await this.usersService.find(this.query.query, this.query, user);
|
|
81
82
|
result.rows.map((user) => {
|
|
82
83
|
delete user.password;
|
|
83
84
|
delete user["2fa-token"];
|
|
@@ -102,7 +103,7 @@ class restController extends nodefony.Controller {
|
|
|
102
103
|
* @Route ( "",name="api-users-post")
|
|
103
104
|
*/
|
|
104
105
|
async postAction() {
|
|
105
|
-
let
|
|
106
|
+
let myuser = null;
|
|
106
107
|
let error = null;
|
|
107
108
|
if (!this.query.password || !this.query.confirm) {
|
|
108
109
|
error = new Error(`Password can't be empty`);
|
|
@@ -116,13 +117,14 @@ class restController extends nodefony.Controller {
|
|
|
116
117
|
}
|
|
117
118
|
try {
|
|
118
119
|
this.checkAuthorisation(null, this.query);
|
|
119
|
-
user =
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
delete
|
|
120
|
+
const user = this.getUser()
|
|
121
|
+
myuser = await this.usersService.create(this.query, user);
|
|
122
|
+
if (myuser) {
|
|
123
|
+
delete myuser.password;
|
|
124
|
+
delete myuser["2fa-token"];
|
|
123
125
|
let res = {
|
|
124
126
|
query: this.query,
|
|
125
|
-
user:
|
|
127
|
+
user: myuser
|
|
126
128
|
};
|
|
127
129
|
return this.api.render(res);
|
|
128
130
|
}
|
|
@@ -134,7 +136,6 @@ class restController extends nodefony.Controller {
|
|
|
134
136
|
this.log(e, "ERROR");
|
|
135
137
|
return this.api.renderError(e, 400);
|
|
136
138
|
}
|
|
137
|
-
|
|
138
139
|
}
|
|
139
140
|
|
|
140
141
|
/**
|
|
@@ -143,7 +144,8 @@ class restController extends nodefony.Controller {
|
|
|
143
144
|
*/
|
|
144
145
|
async putAction(username) {
|
|
145
146
|
this.checkAuthorisation(this.query.username, this.query);
|
|
146
|
-
|
|
147
|
+
const user = this.getUser()
|
|
148
|
+
return this.usersService.findOne(username, user)
|
|
147
149
|
.then(async (myuser) => {
|
|
148
150
|
if (myuser) {
|
|
149
151
|
if (this.query.password) {
|
|
@@ -168,8 +170,8 @@ class restController extends nodefony.Controller {
|
|
|
168
170
|
throw new Error(`User ${username} no confirm passport`);
|
|
169
171
|
}
|
|
170
172
|
}
|
|
171
|
-
return this.usersService.update(myuser, this.query)
|
|
172
|
-
.then(async (
|
|
173
|
+
return this.usersService.update(myuser, this.query, user)
|
|
174
|
+
.then(async (res) => {
|
|
173
175
|
let message = `Update User ${this.query.username} OK`;
|
|
174
176
|
this.log(message, "INFO");
|
|
175
177
|
let currentUser = this.getUser();
|
|
@@ -181,7 +183,7 @@ class restController extends nodefony.Controller {
|
|
|
181
183
|
this.session.set("lang", this.query.lang);
|
|
182
184
|
}
|
|
183
185
|
}
|
|
184
|
-
let newUser = await this.usersService.findOne(this.query.username);
|
|
186
|
+
let newUser = await this.usersService.findOne(this.query.username, user);
|
|
185
187
|
delete newUser.password;
|
|
186
188
|
delete newUser["2fa-token"];
|
|
187
189
|
return this.api.render({
|
|
@@ -202,9 +204,9 @@ class restController extends nodefony.Controller {
|
|
|
202
204
|
* @Method ({"PATCH"})
|
|
203
205
|
* @Route ( "/{username}",name="api-user-patch")
|
|
204
206
|
*/
|
|
207
|
+
// TODO
|
|
205
208
|
async patchAction(username) {
|
|
206
209
|
this.log(username);
|
|
207
|
-
|
|
208
210
|
}
|
|
209
211
|
|
|
210
212
|
/**
|
|
@@ -214,7 +216,8 @@ class restController extends nodefony.Controller {
|
|
|
214
216
|
async deleteAction(username) {
|
|
215
217
|
try {
|
|
216
218
|
this.checkAuthorisation(this.query.username, this.query);
|
|
217
|
-
|
|
219
|
+
const user = this.getUser()
|
|
220
|
+
return this.usersService.delete(username, user)
|
|
218
221
|
.then((user) => {
|
|
219
222
|
delete user.password;
|
|
220
223
|
delete user["2fa-token"];
|
|
@@ -82,6 +82,7 @@ class usersController extends nodefony.Controller {
|
|
|
82
82
|
*
|
|
83
83
|
*/
|
|
84
84
|
createAction() {
|
|
85
|
+
const user = this.getUser();
|
|
85
86
|
switch (this.method) {
|
|
86
87
|
case "GET":
|
|
87
88
|
let size = Object.keys(this.queryGet).length;
|
|
@@ -119,7 +120,7 @@ class usersController extends nodefony.Controller {
|
|
|
119
120
|
this.query.roles = [this.query.roles];
|
|
120
121
|
}
|
|
121
122
|
this.checkAuthorisation(null, this.query);
|
|
122
|
-
return this.usersService.create(this.query)
|
|
123
|
+
return this.usersService.create(this.query, user)
|
|
123
124
|
.then((user) => {
|
|
124
125
|
let message = `${this.translate("added", "users")} ${user.username}`;
|
|
125
126
|
this.setFlashBag("info", message);
|
|
@@ -146,10 +147,11 @@ class usersController extends nodefony.Controller {
|
|
|
146
147
|
* @Route ( "/update/{username}", name="nodefony-user-update")
|
|
147
148
|
*/
|
|
148
149
|
updateAction(username) {
|
|
150
|
+
let user = this.getUser()
|
|
149
151
|
this.checkAuthorisation(username, this.query);
|
|
150
152
|
switch (this.method) {
|
|
151
153
|
case "GET":
|
|
152
|
-
return this.usersService.findOne(username)
|
|
154
|
+
return this.usersService.findOne(username, user)
|
|
153
155
|
.then((result) => {
|
|
154
156
|
if (result) {
|
|
155
157
|
return this.render("users:users:createUser.html.twig", {
|
|
@@ -163,7 +165,7 @@ class usersController extends nodefony.Controller {
|
|
|
163
165
|
throw e;
|
|
164
166
|
});
|
|
165
167
|
case "POST":
|
|
166
|
-
return this.usersService.findOne(username)
|
|
168
|
+
return this.usersService.findOne(username, user)
|
|
167
169
|
.then(async (myuser) => {
|
|
168
170
|
if (myuser) {
|
|
169
171
|
if (nodefony.typeOf(this.query.roles) === "string") {
|
|
@@ -199,7 +201,7 @@ class usersController extends nodefony.Controller {
|
|
|
199
201
|
}
|
|
200
202
|
}
|
|
201
203
|
}
|
|
202
|
-
return this.usersService.update(myuser, value)
|
|
204
|
+
return this.usersService.update(myuser, value, user)
|
|
203
205
|
.then(() => {
|
|
204
206
|
let message = `Update User ${this.query.username} OK`;
|
|
205
207
|
this.setFlashBag("info", message);
|
|
@@ -244,9 +246,10 @@ class usersController extends nodefony.Controller {
|
|
|
244
246
|
*
|
|
245
247
|
*/
|
|
246
248
|
deleteAction(username) {
|
|
249
|
+
let user = this.getUser();
|
|
247
250
|
this.checkAuthorisation(username);
|
|
248
251
|
if (username) {
|
|
249
|
-
return this.usersService.delete(username)
|
|
252
|
+
return this.usersService.delete(username, user)
|
|
250
253
|
.then((result) => {
|
|
251
254
|
let message = `Delete User ${result.username} OK`;
|
|
252
255
|
this.setFlashBag("info", message);
|
|
@@ -272,6 +275,7 @@ class usersController extends nodefony.Controller {
|
|
|
272
275
|
*
|
|
273
276
|
*/
|
|
274
277
|
userAction(username) {
|
|
278
|
+
let user = this.getUser();
|
|
275
279
|
if (username) {
|
|
276
280
|
switch (this.method) {
|
|
277
281
|
case "PUT":
|
|
@@ -280,7 +284,7 @@ class usersController extends nodefony.Controller {
|
|
|
280
284
|
return this.deleteAction(username);
|
|
281
285
|
case "GET":
|
|
282
286
|
//const user = new User(this);
|
|
283
|
-
return this.usersService.findOne(username)
|
|
287
|
+
return this.usersService.findOne(username, user)
|
|
284
288
|
.then((result) => {
|
|
285
289
|
if (result) {
|
|
286
290
|
return this.render("users:users:readUsers.html.twig", {
|
|
@@ -297,7 +301,7 @@ class usersController extends nodefony.Controller {
|
|
|
297
301
|
case "POST":
|
|
298
302
|
return this.createAction();
|
|
299
303
|
default:
|
|
300
|
-
return this.usersService.find()
|
|
304
|
+
return this.usersService.find(this.query,{}, user)
|
|
301
305
|
.then((result) => {
|
|
302
306
|
return this.render("users:users:readUsers.html.twig", {
|
|
303
307
|
users: result.rows
|
|
@@ -16,44 +16,37 @@
|
|
|
16
16
|
],
|
|
17
17
|
"repository": {},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@babel/core": "7.
|
|
20
|
-
"@babel/plugin-proposal-class-properties": "
|
|
19
|
+
"@babel/core": "7.19.0",
|
|
20
|
+
"@babel/plugin-proposal-class-properties": "7.18.6",
|
|
21
21
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
22
|
-
"@babel/preset-env": "
|
|
23
|
-
"@babel/preset-react": "
|
|
24
|
-
"@popperjs/core": "2.11.
|
|
22
|
+
"@babel/preset-env": "7.19.0",
|
|
23
|
+
"@babel/preset-react": "7.18.6",
|
|
24
|
+
"@popperjs/core": "2.11.6",
|
|
25
25
|
"@withshepherd/faker": "5.5.5",
|
|
26
|
-
"babel-loader": "
|
|
26
|
+
"babel-loader": "8.2.5",
|
|
27
27
|
"babel-register": "^6.26.0",
|
|
28
|
-
"bootstrap": "
|
|
28
|
+
"bootstrap": "5.2.1",
|
|
29
29
|
"clean-webpack-plugin": "^4.0.0",
|
|
30
30
|
"css-hot-loader": "^1.4.4",
|
|
31
31
|
"css-loader": "6.7.1",
|
|
32
|
-
"expose-loader": "
|
|
32
|
+
"expose-loader": "4.0.0",
|
|
33
33
|
"font-awesome": "^4.7.0",
|
|
34
|
-
"graphiql": "1.7.1",
|
|
35
|
-
"graphql": "16.3.0",
|
|
36
|
-
"graphql-ws": "5.6.3",
|
|
37
34
|
"html-webpack-plugin": "^5.5.0",
|
|
38
|
-
"imports-loader": "
|
|
39
|
-
"jquery": "
|
|
40
|
-
"mini-css-extract-plugin": "2.6.
|
|
41
|
-
"mongoose-paginate-v2": "1.
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"react-dom": "^17.0.2",
|
|
45
|
-
"sass-loader": "12.6.0",
|
|
35
|
+
"imports-loader": "4.0.1",
|
|
36
|
+
"jquery": "3.6.1",
|
|
37
|
+
"mini-css-extract-plugin": "2.6.1",
|
|
38
|
+
"mongoose-paginate-v2": "1.7.1",
|
|
39
|
+
"sass": "1.54.9",
|
|
40
|
+
"sass-loader": "13.0.2",
|
|
46
41
|
"style-loader": "^3.3.1",
|
|
47
42
|
"svg-inline-loader": "^0.8.2",
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"terser-webpack-plugin": "5.3.1",
|
|
51
|
-
"webpack": "5.70.0",
|
|
43
|
+
"terser-webpack-plugin": "5.3.6",
|
|
44
|
+
"webpack": "5.74.0",
|
|
52
45
|
"webpack-merge": "^5.8.0"
|
|
53
46
|
},
|
|
54
47
|
"devDependencies": {
|
|
55
|
-
"@mapbox/node-pre-gyp": "
|
|
56
|
-
"node-gyp": "9.
|
|
48
|
+
"@mapbox/node-pre-gyp": "1.0.10",
|
|
49
|
+
"node-gyp": "9.1.0",
|
|
57
50
|
"sequelize-cli": "^6.4.1",
|
|
58
51
|
"stream": "0.0.2"
|
|
59
52
|
},
|