@cocreate/users 1.36.7 → 1.36.9
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 +1 -1
- package/src/client.js +18 -14
- package/src/server.js +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.36.9](https://github.com/CoCreate-app/CoCreate-users/compare/v1.36.8...v1.36.9) (2024-04-29)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* check if url is not the same as current prior to applying location.href ([bda51bb](https://github.com/CoCreate-app/CoCreate-users/commit/bda51bb23bc9b3adc19864fcf78c444d1462b781))
|
|
7
|
+
|
|
8
|
+
## [1.36.8](https://github.com/CoCreate-app/CoCreate-users/compare/v1.36.7...v1.36.8) (2024-02-18)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* add host ([f6f6343](https://github.com/CoCreate-app/CoCreate-users/commit/f6f634305aef8ffbbe539366574c1b5949692816))
|
|
14
|
+
|
|
1
15
|
## [1.36.7](https://github.com/CoCreate-app/CoCreate-users/compare/v1.36.6...v1.36.7) (2024-02-18)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -186,27 +186,31 @@ const CoCreateUser = {
|
|
|
186
186
|
if (data.user_id && data.user_id !== Crud.socket.user_id || data.clientId && data.clientId !== Crud.socket.clientId)
|
|
187
187
|
return
|
|
188
188
|
|
|
189
|
+
let redirectTag
|
|
189
190
|
if (data.userStatus == 'on' || data.userStatus == 'idle') {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
if (redirectTag) {
|
|
193
|
-
let redirectLink = redirectTag.getAttribute('href');
|
|
194
|
-
if (redirectLink) {
|
|
195
|
-
document.location.href = redirectLink;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
191
|
+
redirectTag = document.querySelector('[session="true"]');
|
|
199
192
|
} else if (data.userStatus == 'off') {
|
|
200
|
-
|
|
193
|
+
redirectTag = document.querySelector('[session="false"]');
|
|
194
|
+
}
|
|
201
195
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
196
|
+
if (redirectTag) {
|
|
197
|
+
let redirectLink = redirectTag.getAttribute('href');
|
|
198
|
+
if (redirectLink) {
|
|
199
|
+
if (data.userStatus == 'off') {
|
|
205
200
|
localStorage.removeItem("user_id");
|
|
206
201
|
localStorage.removeItem("token");
|
|
207
|
-
document.location.href = redirectLink;
|
|
208
202
|
}
|
|
203
|
+
|
|
204
|
+
// Normalize both URLs to compare paths in a uniform way
|
|
205
|
+
const currentPath = new URL(location.href).pathname.replace('/index.html', '/');
|
|
206
|
+
const targetPath = new URL(redirectLink, location.href).pathname.replace('/index.html', '/');
|
|
207
|
+
|
|
208
|
+
if (currentPath !== targetPath) {
|
|
209
|
+
location.href = redirectLink;
|
|
210
|
+
}
|
|
211
|
+
|
|
209
212
|
}
|
|
213
|
+
|
|
210
214
|
}
|
|
211
215
|
|
|
212
216
|
if (data.userStatus) {
|
package/src/server.js
CHANGED
|
@@ -87,6 +87,7 @@ class CoCreateUser {
|
|
|
87
87
|
self.wsManager.send(response)
|
|
88
88
|
self.wsManager.send({
|
|
89
89
|
socket,
|
|
90
|
+
host: data.host,
|
|
90
91
|
method: 'updateUserStatus',
|
|
91
92
|
user_id: response.user_id,
|
|
92
93
|
userStatus: response.userStatus,
|
|
@@ -120,6 +121,7 @@ class CoCreateUser {
|
|
|
120
121
|
self.wsManager.send({
|
|
121
122
|
socket: data.socket,
|
|
122
123
|
method: 'updateUserStatus',
|
|
124
|
+
host: data.host,
|
|
123
125
|
user_id: data.user_id,
|
|
124
126
|
clientId: data.clientId,
|
|
125
127
|
userStatus: data.userStatus,
|
|
@@ -129,6 +131,7 @@ class CoCreateUser {
|
|
|
129
131
|
} else if (data.socket)
|
|
130
132
|
data.socket.send(JSON.stringify({
|
|
131
133
|
method: 'updateUserStatus',
|
|
134
|
+
host: data.host,
|
|
132
135
|
user_id: data.user_id,
|
|
133
136
|
userStatus: data.userStatus,
|
|
134
137
|
clientId: data.clientId,
|