@cocreate/organizations 1.14.3 → 1.15.0
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 +7 -0
- package/package.json +1 -1
- package/src/client.js +2 -4
- package/src/server.js +19 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.15.0](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.14.3...v1.15.0) (2023-05-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* socket event broadcasting and added user key creation ([cdfe4df](https://github.com/CoCreate-app/CoCreate-organizations/commit/cdfe4df8f217823cfbaff8e5187813cb3a8a4827))
|
|
7
|
+
|
|
1
8
|
## [1.14.3](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.14.2...v1.14.3) (2023-05-20)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -30,19 +30,17 @@ const CoCreateOrganization = {
|
|
|
30
30
|
user = user.document[0]
|
|
31
31
|
|
|
32
32
|
let organization_id = organization._id
|
|
33
|
-
let key = organization.key
|
|
34
33
|
|
|
35
34
|
if (crud.socket.organization !== true) {
|
|
36
35
|
crud.socket.organization = true
|
|
37
|
-
crud.socket.create({ organization_id
|
|
36
|
+
crud.socket.create({ organization_id })
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
let response = await crud.socket.send('createOrganization', {
|
|
41
40
|
organization,
|
|
42
41
|
user,
|
|
43
42
|
broadcastBrowser: false,
|
|
44
|
-
organization_id
|
|
45
|
-
key
|
|
43
|
+
organization_id
|
|
46
44
|
});
|
|
47
45
|
|
|
48
46
|
document.dispatchEvent(new CustomEvent('createdOrganization', {
|
package/src/server.js
CHANGED
|
@@ -30,14 +30,22 @@ class CoCreateOrganization {
|
|
|
30
30
|
owner: data.user._id
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
// TODO: check if user exist and
|
|
33
|
+
// TODO: check if user exist and confirm credentials
|
|
34
34
|
const user = {
|
|
35
35
|
_id: data.user._id,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
firstname: data.user.firtname || 'Admin',
|
|
37
|
+
lastname: data.user.lastname || ''
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const userKey = {
|
|
41
|
+
type: "user",
|
|
42
|
+
key: user._id,
|
|
43
|
+
roles: ['user'],
|
|
44
|
+
email: user.document.email,
|
|
45
|
+
password: user.document.password || btoa('0000'),
|
|
46
|
+
user: {
|
|
47
|
+
collection: 'users'
|
|
48
|
+
}
|
|
41
49
|
}
|
|
42
50
|
|
|
43
51
|
const Data = {}
|
|
@@ -53,6 +61,11 @@ class CoCreateOrganization {
|
|
|
53
61
|
this.wsManager.broadcast(this.platformSocket, 'createDocument', response);
|
|
54
62
|
}
|
|
55
63
|
|
|
64
|
+
if (userKey) {
|
|
65
|
+
const response = await this.crud.createDocument({ ...Data, collection: 'keys', document: userKey })
|
|
66
|
+
this.wsManager.broadcast(this.platformSocket, 'createDocument', response);
|
|
67
|
+
}
|
|
68
|
+
|
|
56
69
|
this.wsManager.send(socket, 'createOrganization', data);
|
|
57
70
|
} catch (error) {
|
|
58
71
|
console.log('createDocument error', error);
|