yaml-admin-api 0.0.94 → 0.0.95
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/package.json
CHANGED
|
@@ -450,13 +450,20 @@ const generateCrud = async ({ app, db, entity_name, yml_entity, yml, options })
|
|
|
450
450
|
|
|
451
451
|
var r = await db.collection(collection_name).insertOne(entity);
|
|
452
452
|
//Custom Create Tail Start
|
|
453
|
-
if(options?.listener?.entityCreated)
|
|
453
|
+
if(options?.listener?.entityCreated) {
|
|
454
|
+
let passwordField = yml_entity.fields.find(f => f.type == 'password')
|
|
455
|
+
if(passwordField)
|
|
456
|
+
entity[passwordField.name] = req.body[passwordField.name]
|
|
454
457
|
await options.listener.entityCreated(db, entity_name, entity)
|
|
458
|
+
}
|
|
455
459
|
//Custom Create Tail End
|
|
456
460
|
|
|
457
461
|
const generatedId = entityId || r.insertedId
|
|
458
462
|
entity.id = (key_field.type == 'objectId') ? generatedId?.toString() : generatedId;
|
|
459
|
-
|
|
463
|
+
let passwordField = yml_entity.fields.find(f => f.type == 'password')
|
|
464
|
+
if(passwordField)
|
|
465
|
+
delete entity[passwordField.name]
|
|
466
|
+
|
|
460
467
|
res.json(entity);
|
|
461
468
|
}));
|
|
462
469
|
|
|
@@ -498,12 +505,19 @@ const generateCrud = async ({ app, db, entity_name, yml_entity, yml, options })
|
|
|
498
505
|
if(options?.listener?.entityUpdated) {
|
|
499
506
|
let entityWithId = { ...entity }
|
|
500
507
|
entityWithId[key_field.name] = entityId
|
|
508
|
+
|
|
509
|
+
let passwordField = yml_entity.fields.find(f => f.type == 'password')
|
|
510
|
+
if(passwordField && req.body[passwordField.name])
|
|
511
|
+
entityWithId[passwordField.name] = req.body[passwordField.name]
|
|
501
512
|
await options.listener.entityUpdated(db, entity_name, entityWithId)
|
|
502
513
|
}
|
|
503
514
|
//Custom Create Tail End
|
|
504
515
|
|
|
505
516
|
// Ensure React-Admin receives an `id` in the response
|
|
506
517
|
entity.id = (key_field.type == 'objectId') ? entityId?.toString() : entityId
|
|
518
|
+
let passwordField = yml_entity.fields.find(f => f.type == 'password')
|
|
519
|
+
if(passwordField)
|
|
520
|
+
delete entity[passwordField.name]
|
|
507
521
|
|
|
508
522
|
res.json(entity);
|
|
509
523
|
}));
|