@adminforth/open-signup 1.1.1 → 1.1.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/build.log CHANGED
@@ -8,5 +8,5 @@ custom/SignupPage.vue
8
8
  custom/SignupUnderLogin.vue
9
9
  custom/tsconfig.json
10
10
 
11
- sent 14,444 bytes received 77 bytes 29,042.00 bytes/sec
12
- total size is 14,155 speedup is 0.97
11
+ sent 14,440 bytes received 77 bytes 29,034.00 bytes/sec
12
+ total size is 14,155 speedup is 0.98
package/dist/index.js CHANGED
@@ -143,17 +143,17 @@ export default class OpenSignupPlugin extends AdminForthPlugin {
143
143
  const { token, password } = body;
144
144
  const { email } = yield this.adminforth.auth.verify(token, 'tempVerifyEmailToken', false);
145
145
  if (!email) {
146
- return { error: 'Invalid token', ok: false };
146
+ return { error: yield tr('Invalid token', 'opensignup'), ok: false };
147
147
  }
148
148
  if (!password) {
149
- return { error: tr('Password is required', 'opensignup'), ok: false };
149
+ return { error: yield tr('Password is required', 'opensignup'), ok: false };
150
150
  }
151
151
  const userRecord = yield this.adminforth.resource(this.authResource.resourceId).get(Filters.EQ(this.emailField.name, email));
152
152
  if (!userRecord) {
153
- return { error: tr('User not found'), ok: false };
153
+ return { error: yield tr('User not found', 'opensignup'), ok: false };
154
154
  }
155
155
  if (userRecord[this.options.confirmEmails.emailConfirmedField]) {
156
- return { error: tr('Email already confirmed'), ok: false };
156
+ return { error: yield tr('Email already confirmed', 'opensignup'), ok: false };
157
157
  }
158
158
  yield this.adminforth.resource(this.authResource.resourceId).update(userRecord[this.authResource.columns.find((col) => col.primaryKey).name], {
159
159
  [this.options.confirmEmails.emailConfirmedField]: true,
@@ -252,7 +252,7 @@ export default class OpenSignupPlugin extends AdminForthPlugin {
252
252
  const brandName = this.adminforth.config.customization.brandName;
253
253
  const verifyToken = this.adminforth.auth.issueJWT({ email, issuer: brandName }, 'tempVerifyEmailToken', '2h');
254
254
  process.env.HEAVY_DEBUG && console.log('🐛Sending reset tok to', verifyToken);
255
- const emailText = tr(`
255
+ const emailText = yield tr(`
256
256
  Dear user,
257
257
  Welcome to {brandName}!
258
258
 
@@ -267,22 +267,32 @@ export default class OpenSignupPlugin extends AdminForthPlugin {
267
267
  The {brandName} Team
268
268
 
269
269
  `, 'opensignup', { brandName, url, verifyToken });
270
- const emailHtml = tr(`
271
- <html>
272
- <head></head>
273
- <body>
274
- <p>Dear user,</p>
275
- <p>Welcome to {brandName}!</p>
276
- <p>To confirm your email, click the link below:</p>
277
- <a href="{url}?token={verifyToken}">Confirm email</a>
278
- <p>If you didn't request this, please ignore this email.</p>
279
- <p>Link is valid for 2 hours.</p>
280
- <p>Thanks,</p>
281
- <p>The {brandName} Team</p>
282
- </body>
283
- </html>
284
- `, 'opensignup', { brandName, url, verifyToken });
285
- const emailSubject = tr(`Signup request at {brandName}`, 'opensignup', { brandName });
270
+ const emailData = {
271
+ greeting: yield tr('Dear user,', 'opensignup'),
272
+ welcome: yield tr('Welcome to {brandName}!', 'opensignup', { brandName }),
273
+ instruction: yield tr('To confirm your email, click the link below:', 'opensignup'),
274
+ linkText: yield tr('Confirm email', 'opensignup'),
275
+ disclaimer: yield tr('If you didn\'t request this, please ignore this email.', 'opensignup'),
276
+ validity: yield tr('Link is valid for 2 hours.', 'opensignup'),
277
+ thanks: yield tr('Thanks,', 'opensignup'),
278
+ team: yield tr('The {brandName} Team', 'opensignup', { brandName }),
279
+ };
280
+ const emailHtml = `
281
+ <html>
282
+ <head></head>
283
+ <body>
284
+ <p>${emailData.greeting}</p>
285
+ <p>${emailData.welcome}</p>
286
+ <p>${emailData.instruction}</p>
287
+ <a href="${url}?token=${verifyToken}">${emailData.linkText}</a>
288
+ <p>${emailData.disclaimer}</p>
289
+ <p>${emailData.validity}</p>
290
+ <p>${emailData.thanks}</p>
291
+ <p>${emailData.team}</p>
292
+ </body>
293
+ </html>
294
+ `;
295
+ const emailSubject = yield tr(`Signup request at {brandName}`, 'opensignup', { brandName });
286
296
  // send email with AWS SES this.options.providerOptions.AWS_SES
287
297
  this.options.confirmEmails.adapter.sendEmail(this.options.confirmEmails.sendFrom, email, emailText, emailHtml, emailSubject);
288
298
  return { ok: true };
package/index.ts CHANGED
@@ -165,19 +165,19 @@ export default class OpenSignupPlugin extends AdminForthPlugin {
165
165
  const { token, password } = body;
166
166
  const { email } = await this.adminforth.auth.verify(token, 'tempVerifyEmailToken', false);
167
167
  if (!email) {
168
- return { error: 'Invalid token', ok: false };
168
+ return { error: await tr('Invalid token', 'opensignup'), ok: false };
169
169
  }
170
170
 
171
171
  if(!password) {
172
- return { error: tr('Password is required', 'opensignup'), ok: false };
172
+ return { error: await tr('Password is required', 'opensignup'), ok: false };
173
173
  }
174
174
  const userRecord = await this.adminforth.resource(this.authResource.resourceId).get(Filters.EQ(this.emailField.name, email));
175
175
  if (!userRecord) {
176
- return { error: tr('User not found'), ok: false };
176
+ return { error: await tr('User not found', 'opensignup'), ok: false };
177
177
  }
178
178
 
179
179
  if (userRecord[this.options.confirmEmails.emailConfirmedField]) {
180
- return { error: tr('Email already confirmed'), ok: false };
180
+ return { error: await tr('Email already confirmed', 'opensignup'), ok: false };
181
181
  }
182
182
 
183
183
  await this.adminforth.resource(this.authResource.resourceId).update(userRecord[this.authResource.columns.find((col) => col.primaryKey).name], {
@@ -294,7 +294,7 @@ export default class OpenSignupPlugin extends AdminForthPlugin {
294
294
 
295
295
  const verifyToken = this.adminforth.auth.issueJWT({email, issuer: brandName }, 'tempVerifyEmailToken', '2h');
296
296
  process.env.HEAVY_DEBUG && console.log('🐛Sending reset tok to', verifyToken);
297
- const emailText = tr(`
297
+ const emailText = await tr(`
298
298
  Dear user,
299
299
  Welcome to {brandName}!
300
300
 
@@ -310,24 +310,34 @@ export default class OpenSignupPlugin extends AdminForthPlugin {
310
310
 
311
311
  `, 'opensignup', { brandName, url, verifyToken }
312
312
  );
313
+
314
+ const emailData = {
315
+ greeting: await tr('Dear user,', 'opensignup'),
316
+ welcome: await tr('Welcome to {brandName}!', 'opensignup', { brandName }),
317
+ instruction: await tr('To confirm your email, click the link below:', 'opensignup'),
318
+ linkText: await tr('Confirm email', 'opensignup'),
319
+ disclaimer: await tr('If you didn\'t request this, please ignore this email.', 'opensignup'),
320
+ validity: await tr('Link is valid for 2 hours.', 'opensignup'),
321
+ thanks: await tr('Thanks,', 'opensignup'),
322
+ team: await tr('The {brandName} Team', 'opensignup', { brandName }),
323
+ };
313
324
 
314
- const emailHtml = tr(`
315
- <html>
316
- <head></head>
317
- <body>
318
- <p>Dear user,</p>
319
- <p>Welcome to {brandName}!</p>
320
- <p>To confirm your email, click the link below:</p>
321
- <a href="{url}?token={verifyToken}">Confirm email</a>
322
- <p>If you didn't request this, please ignore this email.</p>
323
- <p>Link is valid for 2 hours.</p>
324
- <p>Thanks,</p>
325
- <p>The {brandName} Team</p>
326
- </body>
327
- </html>
328
- `, 'opensignup', { brandName, url, verifyToken });
329
-
330
- const emailSubject = tr(`Signup request at {brandName}`, 'opensignup', { brandName });
325
+ const emailHtml = `
326
+ <html>
327
+ <head></head>
328
+ <body>
329
+ <p>${emailData.greeting}</p>
330
+ <p>${emailData.welcome}</p>
331
+ <p>${emailData.instruction}</p>
332
+ <a href="${url}?token=${verifyToken}">${emailData.linkText}</a>
333
+ <p>${emailData.disclaimer}</p>
334
+ <p>${emailData.validity}</p>
335
+ <p>${emailData.thanks}</p>
336
+ <p>${emailData.team}</p>
337
+ </body>
338
+ </html>
339
+ `;
340
+ const emailSubject = await tr(`Signup request at {brandName}`, 'opensignup', { brandName });
331
341
 
332
342
  // send email with AWS SES this.options.providerOptions.AWS_SES
333
343
  this.options.confirmEmails.adapter.sendEmail(this.options.confirmEmails.sendFrom, email, emailText, emailHtml, emailSubject);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/open-signup",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",