@adminforth/open-signup 1.1.1 → 1.1.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/dist/index.js +7 -7
- package/index.ts +7 -7
- package/package.json +1 -1
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,7 +267,7 @@ export default class OpenSignupPlugin extends AdminForthPlugin {
|
|
|
267
267
|
The {brandName} Team
|
|
268
268
|
|
|
269
269
|
`, 'opensignup', { brandName, url, verifyToken });
|
|
270
|
-
const emailHtml = tr(`
|
|
270
|
+
const emailHtml = yield tr(`
|
|
271
271
|
<html>
|
|
272
272
|
<head></head>
|
|
273
273
|
<body>
|
|
@@ -282,7 +282,7 @@ export default class OpenSignupPlugin extends AdminForthPlugin {
|
|
|
282
282
|
</body>
|
|
283
283
|
</html>
|
|
284
284
|
`, 'opensignup', { brandName, url, verifyToken });
|
|
285
|
-
const emailSubject = tr(`Signup request at {brandName}`, 'opensignup', { brandName });
|
|
285
|
+
const emailSubject = yield tr(`Signup request at {brandName}`, 'opensignup', { brandName });
|
|
286
286
|
// send email with AWS SES this.options.providerOptions.AWS_SES
|
|
287
287
|
this.options.confirmEmails.adapter.sendEmail(this.options.confirmEmails.sendFrom, email, emailText, emailHtml, emailSubject);
|
|
288
288
|
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
|
|
|
@@ -311,7 +311,7 @@ export default class OpenSignupPlugin extends AdminForthPlugin {
|
|
|
311
311
|
`, 'opensignup', { brandName, url, verifyToken }
|
|
312
312
|
);
|
|
313
313
|
|
|
314
|
-
const emailHtml = tr(`
|
|
314
|
+
const emailHtml = await tr(`
|
|
315
315
|
<html>
|
|
316
316
|
<head></head>
|
|
317
317
|
<body>
|
|
@@ -327,7 +327,7 @@ export default class OpenSignupPlugin extends AdminForthPlugin {
|
|
|
327
327
|
</html>
|
|
328
328
|
`, 'opensignup', { brandName, url, verifyToken });
|
|
329
329
|
|
|
330
|
-
const emailSubject = tr(`Signup request at {brandName}`, 'opensignup', { brandName });
|
|
330
|
+
const emailSubject = await tr(`Signup request at {brandName}`, 'opensignup', { brandName });
|
|
331
331
|
|
|
332
332
|
// send email with AWS SES this.options.providerOptions.AWS_SES
|
|
333
333
|
this.options.confirmEmails.adapter.sendEmail(this.options.confirmEmails.sendFrom, email, emailText, emailHtml, emailSubject);
|