@adminforth/open-signup 1.1.0 → 1.1.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/dist/index.js +3 -2
- package/index.ts +10 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -210,9 +210,9 @@ export default class OpenSignupPlugin extends AdminForthPlugin {
|
|
|
210
210
|
}
|
|
211
211
|
// create user
|
|
212
212
|
if (!existingUser) {
|
|
213
|
+
let recordToCreate = Object.assign(Object.assign(Object.assign({}, (this.options.defaultFieldValues || {})), (this.options.confirmEmails ? { [this.options.confirmEmails.emailConfirmedField]: false } : {})), { [this.emailField.name]: normalizedEmail, [this.options.passwordHashField]: password ? yield AdminForth.Utils.generatePasswordHash(password) : '' });
|
|
213
214
|
if ((_b = this.options.hooks) === null || _b === void 0 ? void 0 : _b.beforeUserSave) {
|
|
214
215
|
const hook = this.options.hooks.beforeUserSave;
|
|
215
|
-
const recordToCreate = Object.assign(Object.assign(Object.assign({}, (this.options.defaultFieldValues || {})), (this.options.confirmEmails ? { [this.options.confirmEmails.emailConfirmedField]: false } : {})), { [this.emailField.name]: normalizedEmail, [this.options.passwordHashField]: password ? yield AdminForth.Utils.generatePasswordHash(password) : '' });
|
|
216
216
|
const resp = yield hook({
|
|
217
217
|
resource: this.authResource,
|
|
218
218
|
record: recordToCreate,
|
|
@@ -225,8 +225,9 @@ export default class OpenSignupPlugin extends AdminForthPlugin {
|
|
|
225
225
|
if (resp.error) {
|
|
226
226
|
return { error: resp.error };
|
|
227
227
|
}
|
|
228
|
+
recordToCreate = resp.record || recordToCreate;
|
|
228
229
|
}
|
|
229
|
-
const created = yield this.adminforth.resource(this.authResource.resourceId).create(
|
|
230
|
+
const created = yield this.adminforth.resource(this.authResource.resourceId).create(recordToCreate);
|
|
230
231
|
if ((_c = this.options.hooks) === null || _c === void 0 ? void 0 : _c.afterUserSave) {
|
|
231
232
|
const hook = this.options.hooks.afterUserSave;
|
|
232
233
|
const resp = yield hook({
|
package/index.ts
CHANGED
|
@@ -238,14 +238,15 @@ export default class OpenSignupPlugin extends AdminForthPlugin {
|
|
|
238
238
|
|
|
239
239
|
// create user
|
|
240
240
|
if (!existingUser) {
|
|
241
|
+
let recordToCreate = {
|
|
242
|
+
...(this.options.defaultFieldValues || {}),
|
|
243
|
+
...(this.options.confirmEmails ? { [this.options.confirmEmails.emailConfirmedField]: false } : {}),
|
|
244
|
+
[this.emailField.name]: normalizedEmail,
|
|
245
|
+
[this.options.passwordHashField]: password ? await AdminForth.Utils.generatePasswordHash(password) : '',
|
|
246
|
+
};
|
|
247
|
+
|
|
241
248
|
if (this.options.hooks?.beforeUserSave) {
|
|
242
249
|
const hook = this.options.hooks.beforeUserSave;
|
|
243
|
-
const recordToCreate = {
|
|
244
|
-
...(this.options.defaultFieldValues || {}),
|
|
245
|
-
...(this.options.confirmEmails ? { [this.options.confirmEmails.emailConfirmedField]: false } : {}),
|
|
246
|
-
[this.emailField.name]: normalizedEmail,
|
|
247
|
-
[this.options.passwordHashField]: password ? await AdminForth.Utils.generatePasswordHash(password) : '',
|
|
248
|
-
};
|
|
249
250
|
const resp = await hook({
|
|
250
251
|
resource: this.authResource,
|
|
251
252
|
record: recordToCreate,
|
|
@@ -259,13 +260,10 @@ export default class OpenSignupPlugin extends AdminForthPlugin {
|
|
|
259
260
|
if (resp.error) {
|
|
260
261
|
return { error: resp.error };
|
|
261
262
|
}
|
|
263
|
+
recordToCreate = resp.record || recordToCreate;
|
|
262
264
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
...(this.options.confirmEmails ? { [this.options.confirmEmails.emailConfirmedField]: false } : {}),
|
|
266
|
-
[this.emailField.name]: normalizedEmail,
|
|
267
|
-
[this.options.passwordHashField]: password ? await AdminForth.Utils.generatePasswordHash(password) : '',
|
|
268
|
-
});
|
|
265
|
+
|
|
266
|
+
const created = await this.adminforth.resource(this.authResource.resourceId).create(recordToCreate);
|
|
269
267
|
|
|
270
268
|
if (this.options.hooks?.afterUserSave) {
|
|
271
269
|
const hook = this.options.hooks.afterUserSave;
|