Fix new user pre-creation event
* We're abusing Events a bit here, so have to manually track callbacks
This commit is contained in:
parent
e35fc5bf41
commit
2495430fae
20
core/user.js
20
core/user.js
|
@ -525,12 +525,24 @@ module.exports = class User {
|
||||||
return callback(null, trans);
|
return callback(null, trans);
|
||||||
},
|
},
|
||||||
function newUserPreEvent(trans, callback) {
|
function newUserPreEvent(trans, callback) {
|
||||||
Events.emit(Events.getSystemEvents().NewUserPrePersist, {
|
const eventName = Events.getSystemEvents().NewUserPrePersist;
|
||||||
|
const subCount = Events.listenerCount(eventName);
|
||||||
|
if (subCount < 1) {
|
||||||
|
return callback(null, trans);
|
||||||
|
}
|
||||||
|
|
||||||
|
let returned = 0;
|
||||||
|
const cbWrapper = e => {
|
||||||
|
++returned;
|
||||||
|
if (returned >= subCount) {
|
||||||
|
return callback(e, trans);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Events.emit(eventName, {
|
||||||
user: self,
|
user: self,
|
||||||
sessionId: createUserInfo.sessionId,
|
sessionId: createUserInfo.sessionId,
|
||||||
callback: err => {
|
callback: cbWrapper,
|
||||||
return callback(err, trans);
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function saveAll(trans, callback) {
|
function saveAll(trans, callback) {
|
||||||
|
|
Loading…
Reference in New Issue