@cocreate/users 1.17.7 → 1.18.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 CHANGED
@@ -1,3 +1,16 @@
1
+ # [1.18.0](https://github.com/CoCreate-app/CoCreate-users/compare/v1.17.7...v1.18.0) (2023-04-13)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * broadcast new user doc ([244226f](https://github.com/CoCreate-app/CoCreate-users/commit/244226ff818f3f6a2251b0cedd3ab196e02d137e))
7
+
8
+
9
+ ### Features
10
+
11
+ * commented code that send signUp to server, instead it uses crud directly ([ef70d2a](https://github.com/CoCreate-app/CoCreate-users/commit/ef70d2a254cc882d12c6fe5257ecef18327ab276))
12
+ * data-type now handeled by getValue value-type ([4715d3e](https://github.com/CoCreate-app/CoCreate-users/commit/4715d3e95f0bd8d71d170b7c5a5cbfe846e7998a))
13
+
1
14
  ## [1.17.7](https://github.com/CoCreate-app/CoCreate-users/compare/v1.17.6...v1.17.7) (2023-04-11)
2
15
 
3
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/users",
3
- "version": "1.17.7",
3
+ "version": "1.18.0",
4
4
  "description": "A simple users component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "users",
package/src/client.js CHANGED
@@ -15,22 +15,22 @@ const CoCreateUser = {
15
15
 
16
16
  initSocket: function() {
17
17
  const self = this;
18
- crud.listen('signUp', function(data) {
19
- self.setDocumentId('users', data.document[0]._id);
18
+ // crud.listen('signUp', function(data) {
19
+ // self.setDocumentId('users', data.document[0]._id);
20
20
 
21
- render.data({
22
- selector: "[template='signUp']",
23
- data: {
24
- type: 'signUp',
25
- message: 'Succesfully Signed Up',
26
- success: true
27
- }
28
- });
29
-
30
- document.dispatchEvent(new CustomEvent('signUp', {
31
- detail: data
32
- }));
33
- });
21
+ // render.data({
22
+ // selector: "[template='signUp']",
23
+ // data: {
24
+ // type: 'signUp',
25
+ // message: 'Succesfully Signed Up',
26
+ // success: true
27
+ // }
28
+ // });
29
+
30
+ // document.dispatchEvent(new CustomEvent('signUp', {
31
+ // detail: data
32
+ // }));
33
+ // });
34
34
 
35
35
  crud.listen('signIn', (data) => self.signInResponse(data));
36
36
  crud.listen('updateUserStatus', (data) => self.updateUserStatus(data));
@@ -151,28 +151,22 @@ const CoCreateUser = {
151
151
  org_id = crud.socket.config.organization_id;
152
152
 
153
153
  let data = {document: {}};
154
- //. get form data
155
154
  elements.forEach(el => {
156
155
  let name = el.getAttribute('name');
157
156
  let value = el.getValue();
158
157
  if (!name || !value) return;
159
-
160
- if (el.getAttribute('data-type') == 'array') {
161
- value = [value];
162
- }
163
158
  data.document[name] = value;
164
159
  });
165
160
  data['collection'] = 'users'
166
161
  data.document['current_org'] = org_id;
167
162
  data.document['connected_orgs'] = [org_id];
168
163
 
169
- const socket = crud.socket.getSockets()
170
- if (!socket[0] || !socket[0].connected || window && !window.navigator.onLine) {
164
+ // const socket = crud.socket.getSockets()
165
+ // if (!socket[0] || !socket[0].connected || window && !window.navigator.onLine) {
171
166
  // ToDo: can use updateDocument with filter query
172
167
  crud.createDocument(data).then((response) => {
173
168
  self.setDocumentId('users', response.document_id);
174
169
  data.database = org_id
175
- data.document_id = response.document_id
176
170
  data.document['_id'] = response.document_id
177
171
  data.organization_id = org_id
178
172
  crud.createDocument(request).then((response) => {
@@ -191,15 +185,15 @@ const CoCreateUser = {
191
185
 
192
186
  })
193
187
  })
194
- } else {
195
- // ToDo: creates user in platformdb
196
- crud.socket.send('signUp', {
197
- collection: 'users',
198
- ...data,
199
- orgDB: org_id,
200
- broadcastBrowser: false
201
- });
202
- }
188
+ // } else {
189
+ // // ToDo: creates user in platformdb
190
+ // crud.socket.send('signUp', {
191
+ // collection: 'users',
192
+ // ...data,
193
+ // orgDB: org_id,
194
+ // broadcastBrowser: false
195
+ // });
196
+ // }
203
197
  },
204
198
 
205
199
  updateUserStatus: function(data) {
package/src/server.js CHANGED
@@ -21,16 +21,18 @@ class CoCreateUser {
21
21
  // Create new user in config db users collection
22
22
  this.crud.createDocument(data).then((data) => {
23
23
  if (data.document[0] && data.document[0]._id) {
24
- const orgDB = data.orgDB;
24
+ // const orgDB = data.orgDB;
25
25
 
26
26
  // if new orgDb Create new user in new org db users collection
27
27
  // if (orgDB && orgDB != data.organization_id) {
28
28
  // let Data = {...data, organization_id: orgDB}
29
29
  // self.crud.createDocument(Data)
30
30
  // }
31
-
31
+
32
+ self.wsManager.broadcast(socket, 'updateDocument', data);
32
33
  self.wsManager.send(socket, 'signUp', data);
33
34
 
35
+
34
36
  // add new user to platformDB
35
37
  if (data.organization_id != process.env.organization_id) {
36
38
  let Data = {...data, organization_id: process.env.organization_id}