@cocreate/organizations 1.14.3 → 1.15.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/CHANGELOG.md +14 -0
- package/package.json +4 -4
- package/src/client.js +2 -4
- package/src/server.js +19 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.15.1](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.15.0...v1.15.1) (2023-05-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Update dependencies versions for [@cocreate](https://github.com/cocreate) libraries ([82e8971](https://github.com/CoCreate-app/CoCreate-organizations/commit/82e89715803b39c55f144e688486401897ac1dc3))
|
|
7
|
+
|
|
8
|
+
# [1.15.0](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.14.3...v1.15.0) (2023-05-21)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* socket event broadcasting and added user key creation ([cdfe4df](https://github.com/CoCreate-app/CoCreate-organizations/commit/cdfe4df8f217823cfbaff8e5187813cb3a8a4827))
|
|
14
|
+
|
|
1
15
|
## [1.14.3](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.14.2...v1.14.3) (2023-05-20)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/organizations",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.1",
|
|
4
4
|
"description": "A simple organizations component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"organizations",
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@cocreate/actions": "^1.8.11",
|
|
63
|
-
"@cocreate/crud-client": "^1.21.
|
|
64
|
-
"@cocreate/docs": "^1.7.
|
|
63
|
+
"@cocreate/crud-client": "^1.21.4",
|
|
64
|
+
"@cocreate/docs": "^1.7.12",
|
|
65
65
|
"@cocreate/form": "^1.14.11",
|
|
66
|
-
"@cocreate/indexeddb": "^1.
|
|
66
|
+
"@cocreate/indexeddb": "^1.10.0"
|
|
67
67
|
}
|
|
68
68
|
}
|
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);
|