@cocreate/users 1.22.1 → 1.22.2
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 +7 -0
- package/package.json +4 -4
- package/src/client.js +7 -6
- package/src/server.js +13 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.22.2](https://github.com/CoCreate-app/CoCreate-users/compare/v1.22.1...v1.22.2) (2023-05-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Refactor authentication flow for CoCreateUser ([25bd324](https://github.com/CoCreate-app/CoCreate-users/commit/25bd324bd04d0c196161f4e93b48589c80acee41))
|
|
7
|
+
|
|
1
8
|
## [1.22.1](https://github.com/CoCreate-app/CoCreate-users/compare/v1.22.0...v1.22.1) (2023-05-21)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/users",
|
|
3
|
-
"version": "1.22.
|
|
3
|
+
"version": "1.22.2",
|
|
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",
|
|
@@ -60,11 +60,11 @@
|
|
|
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/element-prototype": "^1.8.11",
|
|
66
66
|
"@cocreate/form": "^1.14.11",
|
|
67
67
|
"@cocreate/local-storage": "^1.7.2",
|
|
68
|
-
"@cocreate/render": "^1.24.
|
|
68
|
+
"@cocreate/render": "^1.24.12"
|
|
69
69
|
}
|
|
70
70
|
}
|
package/src/client.js
CHANGED
|
@@ -95,9 +95,9 @@ const CoCreateUser = {
|
|
|
95
95
|
|
|
96
96
|
let request = {
|
|
97
97
|
collection,
|
|
98
|
-
document: {
|
|
99
|
-
|
|
100
|
-
},
|
|
98
|
+
// document: {
|
|
99
|
+
// lastSignIn: new Date().toISOString()
|
|
100
|
+
// },
|
|
101
101
|
filter: {
|
|
102
102
|
query
|
|
103
103
|
}
|
|
@@ -105,12 +105,13 @@ const CoCreateUser = {
|
|
|
105
105
|
|
|
106
106
|
const socket = crud.socket.getSockets()
|
|
107
107
|
if (!socket[0] || !socket[0].connected || window && !window.navigator.onLine || crud.socket.serverOrganization == false) {
|
|
108
|
-
crud.
|
|
108
|
+
crud.readDocument(request).then((response) => {
|
|
109
109
|
response['success'] = false
|
|
110
110
|
response['status'] = "signIn failed"
|
|
111
111
|
if (response.document && response.document[0]) {
|
|
112
112
|
response['success'] = true
|
|
113
113
|
response['status'] = "success"
|
|
114
|
+
response['user_id'] = response.document[0].key
|
|
114
115
|
this.signInResponse(response)
|
|
115
116
|
} else {
|
|
116
117
|
this.signInResponse(response)
|
|
@@ -125,13 +126,13 @@ const CoCreateUser = {
|
|
|
125
126
|
},
|
|
126
127
|
|
|
127
128
|
signInResponse: function (data) {
|
|
128
|
-
let { success, status, message, token } = data;
|
|
129
|
+
let { success, status, message, user_id, token } = data;
|
|
129
130
|
|
|
130
131
|
if (success) {
|
|
131
132
|
localStorage.setItem('organization_id', crud.socket.config.organization_id);
|
|
132
133
|
localStorage.setItem("key", crud.socket.config.key);
|
|
133
134
|
localStorage.setItem("host", crud.socket.config.host);
|
|
134
|
-
localStorage.setItem('user_id',
|
|
135
|
+
localStorage.setItem('user_id', user_id);
|
|
135
136
|
localStorage.setItem("token", token);
|
|
136
137
|
// document.cookie = `token=${token};path=/`;
|
|
137
138
|
message = "Succesful signIn";
|
package/src/server.js
CHANGED
|
@@ -48,41 +48,36 @@ class CoCreateUser {
|
|
|
48
48
|
async signIn(socket, data) {
|
|
49
49
|
const self = this;
|
|
50
50
|
try {
|
|
51
|
-
data.
|
|
52
|
-
this.crud.updateDocument(data).then(async (data) => {
|
|
51
|
+
this.crud.readDocument(data).then(async (data) => {
|
|
53
52
|
let response = {
|
|
54
|
-
...data,
|
|
55
53
|
success: false,
|
|
56
54
|
message: "signIn failed",
|
|
57
55
|
status: "failed",
|
|
58
56
|
userStatus: 'off'
|
|
59
57
|
}
|
|
60
58
|
|
|
61
|
-
if (data.document[0] && data.document[0]._id) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
token = await self.wsManager.authInstance.generateToken({ user_id: data.document[0]._id });
|
|
65
|
-
}
|
|
59
|
+
if (data.document[0] && data.document[0]._id && self.wsManager.authInstance) {
|
|
60
|
+
const user_id = data.document[0].key
|
|
61
|
+
const token = await self.wsManager.authInstance.generateToken({ user_id });
|
|
66
62
|
|
|
67
|
-
if (token && token != 'null')
|
|
63
|
+
if (token && token != 'null') {
|
|
68
64
|
response = {
|
|
69
|
-
...response,
|
|
70
65
|
success: true,
|
|
71
66
|
message: "signIn successful",
|
|
72
67
|
status: "success",
|
|
73
68
|
userStatus: 'on',
|
|
69
|
+
user_id,
|
|
74
70
|
token
|
|
75
71
|
};
|
|
76
72
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
Data.document['
|
|
81
|
-
Data.document['
|
|
82
|
-
Data
|
|
83
|
-
|
|
73
|
+
// if (data.organization_id != process.env.organization_id) {
|
|
74
|
+
// let Data = { organization_id: process.env.organization_id }
|
|
75
|
+
// Data.document['_id'] = data.document[0]._id
|
|
76
|
+
// Data.document['lastsignIn'] = data.document[0].lastsignIn
|
|
77
|
+
// Data.document['organization_id'] = process.env.organization_id
|
|
78
|
+
// crud.updateDocument(Data)
|
|
79
|
+
// }
|
|
84
80
|
}
|
|
85
|
-
|
|
86
81
|
}
|
|
87
82
|
self.wsManager.send(socket, 'signIn', response)
|
|
88
83
|
self.wsManager.broadcast(socket, 'updateUserStatus', {
|