Patch auditSource if owner is creating himself an account

This commit is contained in:
Johannes Zellner
2019-01-19 14:34:49 +01:00
parent 4c4f3d04e9
commit dae52089e3

View File

@@ -203,6 +203,12 @@ function create(username, password, email, displayName, options, auditSource, ca
if (error && error.reason === DatabaseError.ALREADY_EXISTS) return callback(new UsersError(UsersError.ALREADY_EXISTS, error.message));
if (error) return callback(new UsersError(UsersError.INTERNAL_ERROR, error));
// when this is used to create the owner, then we have to patch the auditSource to contain himself
if (isOwner) {
auditSource.userId = user.id;
auditSource.username = user.username;
}
eventlog.add(eventlog.ACTION_USER_ADD, auditSource, { userId: user.id, email: user.email, user: removePrivateFields(user), invitor: invitor });
callback(null, user);