@cocreate/users 1.19.1 → 1.19.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,18 @@
1
+ ## [1.19.3](https://github.com/CoCreate-app/CoCreate-users/compare/v1.19.2...v1.19.3) (2023-04-24)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * bump [@cocreate](https://github.com/cocreate) dependencies ([7c8614d](https://github.com/CoCreate-app/CoCreate-users/commit/7c8614dcfe06e5a5bb1bdd95987187a2bb255afa))
7
+
8
+ ## [1.19.2](https://github.com/CoCreate-app/CoCreate-users/compare/v1.19.1...v1.19.2) (2023-04-24)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * typo ([7e34148](https://github.com/CoCreate-app/CoCreate-users/commit/7e3414843f3bef3cd3dc7fe42f45cb55ade0442f))
14
+ * userStatus redirect conditions ([0d32f10](https://github.com/CoCreate-app/CoCreate-users/commit/0d32f10d60f18d1270ba5fb1702cadc9d9a39934))
15
+
1
16
  ## [1.19.1](https://github.com/CoCreate-app/CoCreate-users/compare/v1.19.0...v1.19.1) (2023-04-24)
2
17
 
3
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/users",
3
- "version": "1.19.1",
3
+ "version": "1.19.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",
@@ -59,11 +59,11 @@
59
59
  "webpack-log": "^3.0.1"
60
60
  },
61
61
  "dependencies": {
62
- "@cocreate/actions": "^1.6.5",
63
- "@cocreate/crud-client": "^1.19.5",
64
- "@cocreate/docs": "^1.6.5",
65
- "@cocreate/element-prototype": "^1.6.5",
66
- "@cocreate/local-storage": "^1.5.5",
67
- "@cocreate/render": "^1.22.6"
62
+ "@cocreate/actions": "^1.8.1",
63
+ "@cocreate/crud-client": "^1.19.8",
64
+ "@cocreate/docs": "^1.7.0",
65
+ "@cocreate/element-prototype": "^1.8.1",
66
+ "@cocreate/local-storage": "^1.6.1",
67
+ "@cocreate/render": "^1.24.1"
68
68
  }
69
69
  }
package/src/client.js CHANGED
@@ -209,7 +209,11 @@ const CoCreateUser = {
209
209
  },
210
210
 
211
211
  redirect: (data) => {
212
- if (data.userStatus == 'on') {
212
+ if (data.user_id && data.user_id !== crud.socket.config.user_id)
213
+ return
214
+ if (!data.user_id && data.clientId !== crud.socket.clientId)
215
+ return
216
+ if (data.userStatus == 'on' || data.userStatus == 'idle') {
213
217
  let redirectTag = document.querySelector('[session="true"]');
214
218
 
215
219
  if (redirectTag) {
@@ -218,7 +222,7 @@ const CoCreateUser = {
218
222
  document.location.href = redirectLink;
219
223
  }
220
224
  }
221
- } else {
225
+ } else if (data.userStatus == 'off') {
222
226
  let redirectTag = document.querySelector('[session="false"]');
223
227
 
224
228
  if (redirectTag) {
package/src/server.js CHANGED
@@ -66,7 +66,8 @@ class CoCreateUser {
66
66
  ...data,
67
67
  success: false,
68
68
  message: "signIn failed",
69
- status: "failed"
69
+ status: "failed",
70
+ userStatus: 'off'
70
71
  }
71
72
 
72
73
  if (data.document[0] && data.document[0]._id) {
@@ -95,7 +96,11 @@ class CoCreateUser {
95
96
 
96
97
  }
97
98
  self.wsManager.send(socket, 'signIn', response)
98
- self.wsManager.broadcast(socket, 'updateUserStatus', data)
99
+ self.wsManager.broadcast(socket, 'updateUserStatus', {
100
+ user_id: response.user_id,
101
+ userStatus: response.userStatus,
102
+ organization_id: response.organization_id
103
+ })
99
104
  })
100
105
 
101
106
  } catch (error) {
@@ -110,6 +115,8 @@ class CoCreateUser {
110
115
  async userStatus(socket, data) {
111
116
  const self = this;
112
117
  try {
118
+ if (!data.user_id || !data.userStatus)
119
+ return
113
120
  data.collection = 'users'
114
121
  data['document'] = {
115
122
  _id: data.user_id,
@@ -117,7 +124,13 @@ class CoCreateUser {
117
124
  }
118
125
 
119
126
  this.crud.updateDocument(data).then((data) => {
120
- self.wsManager.broadcast(socket, 'updateUserStatus', data)
127
+ // self.wsManager.broadcast(socket, 'updateUserStatus', data)
128
+ self.wsManager.broadcast(socket, 'updateUserStatus', {
129
+ user_id: data.user_id,
130
+ userStatus: data.userStatus,
131
+ organization_id: data.organization_id || socket.config.organization_id
132
+ })
133
+
121
134
  })
122
135
 
123
136
  } catch (error) {