@cocreate/users 1.5.0 → 1.5.3

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,26 @@
1
+ ## [1.5.3](https://github.com/CoCreate-app/CoCreate-users/compare/v1.5.2...v1.5.3) (2022-05-06)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * replace ObjectID with ObjectId due to mongodb depreciation ([0e7f5be](https://github.com/CoCreate-app/CoCreate-users/commit/0e7f5beba78bb71937a97fb3224d63b9c7c711db))
7
+ * update config organization_Id to organization_id ([929f871](https://github.com/CoCreate-app/CoCreate-users/commit/929f871205441c86b4024f07f239338abd52995f))
8
+
9
+ ## [1.5.2](https://github.com/CoCreate-app/CoCreate-users/compare/v1.5.1...v1.5.2) (2022-05-03)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * removed localstorage.setItem for admin_ui and builder_ui ([350f289](https://github.com/CoCreate-app/CoCreate-users/commit/350f289f731bf21f535d892b276708044eb662a3))
15
+ * user permission typo contained duplicate delete switch case. renamed one to update ([66f6fc7](https://github.com/CoCreate-app/CoCreate-users/commit/66f6fc72ce3b60facaaa41112246de22358062dd))
16
+
17
+ ## [1.5.1](https://github.com/CoCreate-app/CoCreate-users/compare/v1.5.0...v1.5.1) (2022-03-06)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * update param roomInfo to socketInfo ([6784138](https://github.com/CoCreate-app/CoCreate-users/commit/6784138e71feb00866cb8159b1d3c95136b5f00d))
23
+
1
24
  # [1.5.0](https://github.com/CoCreate-app/CoCreate-users/compare/v1.4.35...v1.5.0) (2022-03-03)
2
25
 
3
26
 
@@ -1,7 +1,7 @@
1
1
  module.exports = {
2
2
  "config": {
3
3
  "apiKey": "2061acef-0451-4545-f754-60cf8160",
4
- "organization_Id": "5ff747727005da1c272740ab",
4
+ "organization_id": "5ff747727005da1c272740ab",
5
5
  "host": "general.cocreate.app"
6
6
  },
7
7
 
package/demo/index.html CHANGED
@@ -13,7 +13,7 @@
13
13
  <script>
14
14
  var config = {
15
15
  apiKey: 'c2b08663-06e3-440c-ef6f-13978b42883a',
16
- organization_Id: '5de0387b12e200ea63204d6c',
16
+ organization_id: '5de0387b12e200ea63204d6c',
17
17
  host: 'ws.cocreate.app'
18
18
  }
19
19
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/users",
3
- "version": "1.5.0",
3
+ "version": "1.5.3",
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
@@ -7,7 +7,6 @@ import render from '@cocreate/render';
7
7
  const CONST_PERMISSION_CLASS = 'checkPermission';
8
8
 
9
9
  const CoCreateUser = {
10
- // masterDB: '5ae0cfac6fb8c4e656fdaf92', // '5ae0cfac6fb8c4e656fdaf92' /** masterDB **/,
11
10
  init: function() {
12
11
  this.updatedCurrentOrg = false;
13
12
  this.initSocket();
@@ -69,7 +68,7 @@ const CoCreateUser = {
69
68
 
70
69
  crud.send('login', {
71
70
  "apiKey": window.config.apiKey,
72
- "organization_id": window.config.organization_Id,
71
+ "organization_id": window.config.organization_id,
73
72
  "collection": collection,
74
73
  "loginData": loginData
75
74
  });
@@ -79,7 +78,7 @@ const CoCreateUser = {
79
78
  let { success, status, message, token } = data;
80
79
 
81
80
  if (success) {
82
- window.localStorage.setItem('organization_id', window.config.organization_Id);
81
+ window.localStorage.setItem('organization_id', window.config.organization_id);
83
82
  window.localStorage.setItem("apiKey", window.config.apiKey);
84
83
  window.localStorage.setItem("host", window.config.host);
85
84
  window.localStorage.setItem('user_id', data['id']);
@@ -108,7 +107,7 @@ const CoCreateUser = {
108
107
  getCurrentOrg: function(user_id, collection) {
109
108
  crud.send('usersCurrentOrg', {
110
109
  "apiKey": window.config.apiKey,
111
- "organization_id": window.config.organization_Id,
110
+ "organization_id": window.config.organization_id,
112
111
  "collection": collection || 'users',
113
112
  "user_id": user_id,
114
113
  });
@@ -120,8 +119,8 @@ const CoCreateUser = {
120
119
  window.localStorage.setItem('organization_id', data['current_org']);
121
120
  window.localStorage.setItem('host', window.config.host);
122
121
 
123
- window.localStorage.setItem('adminUI_id', data['adminUI_id']);
124
- window.localStorage.setItem('builderUI_id', data['builderUI_id']);
122
+ // window.localStorage.setItem('adminUI_id', data['adminUI_id']);
123
+ // window.localStorage.setItem('builderUI_id', data['builderUI_id']);
125
124
 
126
125
  document.dispatchEvent(new CustomEvent('logIn'));
127
126
  },
@@ -214,7 +213,7 @@ const CoCreateUser = {
214
213
  case 'read':
215
214
  tag.style.display = 'none';
216
215
  break;
217
- case 'delete':
216
+ case 'update':
218
217
  tag.style.display = 'none';
219
218
  break;
220
219
  case 'delete':
@@ -264,11 +263,11 @@ const CoCreateUser = {
264
263
  let newOrg_id = form.querySelector("input[collection='organizations'][name='_id']");
265
264
  let user_id = form.querySelector("input[collection='users'][name='_id']");
266
265
 
267
- const room = config.organization_Id;
266
+ const room = config.organization_id;
268
267
 
269
268
  crud.send('createUserNew', {
270
269
  apiKey: config.apiKey,
271
- organization_id: config.organization_Id,
270
+ organization_id: config.organization_id,
272
271
  collection: 'users',
273
272
  newOrg_id: org_id,
274
273
  user_id: user_id,
@@ -300,14 +299,13 @@ const CoCreateUser = {
300
299
  });
301
300
  data['current_org'] = org_id;
302
301
  data['connected_orgs'] = [org_id];
303
- data['organization_id'] = config.organization_Id;
302
+ data['organization_id'] = config.organization_id;
304
303
 
305
- const room = config.organization_Id;
304
+ const room = config.organization_id;
306
305
 
307
306
  crud.send('createUser', {
308
307
  apiKey: config.apiKey,
309
- organization_id: config.organization_Id,
310
- // mdb: this.masterDB,
308
+ organization_id: config.organization_id,
311
309
  collection: 'users',
312
310
  data: data,
313
311
  orgDB: org_id
package/src/server.js CHANGED
@@ -1,4 +1,4 @@
1
- const {ObjectID} = require("mongodb");
1
+ const {ObjectId} = require("mongodb");
2
2
 
3
3
  class CoCreateUser {
4
4
  constructor(wsManager, dbClient) {
@@ -9,12 +9,12 @@ class CoCreateUser {
9
9
 
10
10
  init() {
11
11
  if (this.wsManager) {
12
- this.wsManager.on('createUserNew', (socket, data, roomInfo) => this.createUserNew(socket, data));
13
- this.wsManager.on('createUser', (socket, data, roomInfo) => this.createUser(socket, data));
14
- this.wsManager.on('login', (socket, data, roomInfo) => this.login(socket, data, roomInfo))
15
- this.wsManager.on('usersCurrentOrg', (socket, data, roomInfo) => this.usersCurrentOrg(socket, data, roomInfo))
16
- this.wsManager.on('fetchUser', (socket, data, roomInfo) => this.fetchUser(socket, data, roomInfo))
17
- this.wsManager.on('userStatus', (socket, data, roomInfo) => this.setUserStatus(socket, data, roomInfo))
12
+ this.wsManager.on('createUserNew', (socket, data, socketInfo) => this.createUserNew(socket, data));
13
+ this.wsManager.on('createUser', (socket, data, socketInfo) => this.createUser(socket, data));
14
+ this.wsManager.on('login', (socket, data, socketInfo) => this.login(socket, data, socketInfo))
15
+ this.wsManager.on('usersCurrentOrg', (socket, data, socketInfo) => this.usersCurrentOrg(socket, data, socketInfo))
16
+ this.wsManager.on('fetchUser', (socket, data, socketInfo) => this.fetchUser(socket, data, socketInfo))
17
+ this.wsManager.on('userStatus', (socket, data, socketInfo) => this.setUserStatus(socket, data, socketInfo))
18
18
  }
19
19
  }
20
20
 
@@ -28,7 +28,7 @@ class CoCreateUser {
28
28
  const db = this.dbClient.db(req_data['organization_id']);
29
29
  const collection = db.collection(req_data["collection"]);
30
30
  const query = {
31
- "_id": new ObjectID(data["user_id"])
31
+ "_id": new ObjectId(data["user_id"])
32
32
  };
33
33
 
34
34
  collection.find(query).toArray(function(error, result) {
@@ -154,7 +154,7 @@ class CoCreateUser {
154
154
 
155
155
  let query = new Object();
156
156
 
157
- query['_id'] = new ObjectID(req_data['user_id']);
157
+ query['_id'] = new ObjectId(req_data['user_id']);
158
158
 
159
159
  collection.find(query).toArray(function(error, result) {
160
160
 
@@ -164,7 +164,7 @@ class CoCreateUser {
164
164
  let org_id = result[0]['current_org'];
165
165
  const orgCollection = self.dbClient.db(selectedDB).collection('organizations');
166
166
 
167
- orgCollection.find({"_id": new ObjectID(org_id),}).toArray(function(err, res) {
167
+ orgCollection.find({"_id": new ObjectId(org_id),}).toArray(function(err, res) {
168
168
  if (!err && res && res.length > 0) {
169
169
  self.wsManager.send(socket, 'usersCurrentOrg', {
170
170
  id: req_data['id'],
@@ -211,7 +211,7 @@ class CoCreateUser {
211
211
  const collection = self.dbClient.db(selectedDB).collection(req_data['collection']);
212
212
  const user_id = req_data['user_id'];
213
213
  const query = {
214
- "_id": new ObjectID(user_id),
214
+ "_id": new ObjectId(user_id),
215
215
  }
216
216
 
217
217
  collection.findOne(query, function(error, result) {
@@ -227,7 +227,7 @@ class CoCreateUser {
227
227
  /**
228
228
  * status: 'on/off/idle'
229
229
  */
230
- async setUserStatus(socket, req_data, roomInfo) {
230
+ async setUserStatus(socket, req_data, socketInfo) {
231
231
  const self = this;
232
232
  const {info, status} = req_data;
233
233
 
@@ -245,7 +245,7 @@ class CoCreateUser {
245
245
  const collection = self.dbClient.db(selectedDB).collection('users');
246
246
  const user_id = items[1];
247
247
  const query = {
248
- "_id": new ObjectID(user_id),
248
+ "_id": new ObjectId(user_id),
249
249
  }
250
250
  collection.update(query, {$set: {status: status}}, function(err, res) {
251
251
  if (!err) {