@cocreate/users 1.35.1 → 1.36.0

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,10 @@
1
+ # [1.36.0](https://github.com/CoCreate-app/CoCreate-users/compare/v1.35.1...v1.36.0) (2024-02-15)
2
+
3
+
4
+ ### Features
5
+
6
+ * get _id of invitee ([0d92cd9](https://github.com/CoCreate-app/CoCreate-users/commit/0d92cd920189bb80de7dffcf7778340540c5f12e))
7
+
1
8
  ## [1.35.1](https://github.com/CoCreate-app/CoCreate-users/compare/v1.35.0...v1.35.1) (2024-02-13)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/users",
3
- "version": "1.35.1",
3
+ "version": "1.36.0",
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,21 @@ 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
+ array: 'users',
175
+ $filter: {
176
+ query: { email: data.email },
177
+ limit: 1
178
+ },
179
+ organization_id: data.organization_id
180
+ })
181
+
182
+ if (invitee.object[0]) {
183
+ invitee = invitee.object[0]._id
184
+ } else
185
+ invitee = ''
186
+
170
187
  let htmlBody = `
171
188
  <html>
172
189
  <head>
@@ -177,12 +194,12 @@ class CoCreateUser {
177
194
 
178
195
  <p>You have been invited to join ${data.name} on Yellow Oracle.</p>
179
196
 
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>
197
+ <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
198
 
182
199
  <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
200
 
184
201
  <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>
202
+ <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
203
 
187
204
  <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
205
 
@@ -210,7 +227,7 @@ class CoCreateUser {
210
227
  this.wsManager.emit('postmark', email);
211
228
 
212
229
  let response = {
213
- socket: data.socket,
230
+ socket,
214
231
  host: data.host,
215
232
  method: 'inviteUser',
216
233
  success: true,