@cocreate/users 1.35.1 → 1.36.1

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,17 @@
1
+ ## [1.36.1](https://github.com/CoCreate-app/CoCreate-users/compare/v1.36.0...v1.36.1) (2024-02-15)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * missing host ([a3f4e02](https://github.com/CoCreate-app/CoCreate-users/commit/a3f4e02f4a52e0f03ddd890484a6c6a838f8945b))
7
+
8
+ # [1.36.0](https://github.com/CoCreate-app/CoCreate-users/compare/v1.35.1...v1.36.0) (2024-02-15)
9
+
10
+
11
+ ### Features
12
+
13
+ * get _id of invitee ([0d92cd9](https://github.com/CoCreate-app/CoCreate-users/commit/0d92cd920189bb80de7dffcf7778340540c5f12e))
14
+
1
15
  ## [1.35.1](https://github.com/CoCreate-app/CoCreate-users/compare/v1.35.0...v1.35.1) (2024-02-13)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/users",
3
- "version": "1.35.1",
3
+ "version": "1.36.1",
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/server.js CHANGED
@@ -158,6 +158,8 @@ class CoCreateUser {
158
158
  async inviteUser(data) {
159
159
  try {
160
160
  const inviteId = this.crud.ObjectId().toString()
161
+ let socket = data.socket
162
+ delete data.socket
161
163
  let uid = data.uid
162
164
  delete data.uid
163
165
 
@@ -167,6 +169,22 @@ class CoCreateUser {
167
169
 
168
170
  data = await this.crud.send(data)
169
171
 
172
+ let invitee = await this.crud.send({
173
+ method: 'object.read',
174
+ host: data.host,
175
+ array: 'users',
176
+ $filter: {
177
+ query: { email: data.email },
178
+ limit: 1
179
+ },
180
+ organization_id: data.organization_id
181
+ })
182
+
183
+ if (invitee.object[0]) {
184
+ invitee = invitee.object[0]._id
185
+ } else
186
+ invitee = ''
187
+
170
188
  let htmlBody = `
171
189
  <html>
172
190
  <head>
@@ -177,12 +195,12 @@ class CoCreateUser {
177
195
 
178
196
  <p>You have been invited to join ${data.name} on Yellow Oracle.</p>
179
197
 
180
- <p><a href="${data.origin}${data.path}?email=${data.email}&token=${inviteId}&user_id=${data.user_id}&name=${data.name}" style="color: #ffffff; background-color: #FFD700; padding: 10px 20px; text-decoration: none; border-radius: 5px;">Accept Your Invitation</a></p>
198
+ <p><a href="${data.origin}${data.path}?email=${data.email}&token=${inviteId}&user_id=${invitee}&name=${data.name}" style="color: #ffffff; background-color: #FFD700; padding: 10px 20px; text-decoration: none; border-radius: 5px;">Accept Your Invitation</a></p>
181
199
 
182
200
  <p>Please note, this invitation link will expire in 48 hours. We encourage you to accept it soon to begin your journey with ${data.name} on Yellow Oracle.</p>
183
201
 
184
202
  <p>If the button above doesn't work, you can copy and paste the following URL into your web browser:</p>
185
- <p><a href="${data.origin}${data.path}?email=${data.email}&token=${inviteId}&user_id=${data.user_id}&name=${data.name}">${data.origin}${data.path}?email=${data.email}&token=${inviteId}&user_id=${data.user_id}&name=${data.name}</a></p>
203
+ <p><a href="${data.origin}${data.path}?email=${data.email}&token=${inviteId}&user_id=${invitee}&name=${data.name}">${data.origin}${data.path}?email=${data.email}&token=${inviteId}&user_id=${invitee}&name=${data.name}</a></p>
186
204
 
187
205
  <p>If you received this invitation by mistake or have any questions, please don't hesitate to get in touch with our support team at <a href="mailto:support@${data.hostname}">support@${data.hostname}</a>.</p>
188
206
 
@@ -210,7 +228,7 @@ class CoCreateUser {
210
228
  this.wsManager.emit('postmark', email);
211
229
 
212
230
  let response = {
213
- socket: data.socket,
231
+ socket,
214
232
  host: data.host,
215
233
  method: 'inviteUser',
216
234
  success: true,
@@ -268,7 +286,7 @@ class CoCreateUser {
268
286
  data.socket = socket
269
287
  data.object = { _id: object._id, '$addToSet.members': data.user_id }
270
288
  data = await this.crud.send(data)
271
- this.crud.send({ method: 'object.update', array: 'users', object: { _id: data.user_id, memberAccount: object._id, subscription: '6571fe530c48ef6970900a82' } })
289
+ this.crud.send({ method: 'object.update', host: data.host, array: 'users', object: { _id: data.user_id, memberAccount: object._id, subscription: '6571fe530c48ef6970900a82' } })
272
290
  response.success = true
273
291
  response.message = "Invite Accepted"
274
292
  break