let createdUserIds = [];
const tempPinIds = [];

const rnd = () => Math.round(Math.random() * 10000);

const createTestUser = (app, opt) => async ({
	// required fields for user
	firstName = 'Max',
	lastName = 'Mustermann',
	birthday = undefined,
	email = `max${`${Date.now()}_${rnd()}`}@mustermann.de`,
	schoolId = opt.schoolId,
	accounts = [], // test if it has a effect
	roles = [],
	discoverable = false,
	firstLogin = false,
	// manual cleanup, e.g. when testing delete:
	manualCleanup = false,
} = {}) => {
	const registrationPin = await app.service('registrationPins').create({ email, verified: true, silent: true });
	tempPinIds.push(registrationPin);

	const user = await app.service('users').create({
		firstName,
		lastName,
		birthday,
		email,
		schoolId,
		accounts,
		roles,
		discoverable,
		preferences: {
			firstLogin,
		},
	});

	if (!manualCleanup) {
		createdUserIds.push(user._id.toString());
	}
	return user;
};

const cleanup = (app) => () => {
	const ids = createdUserIds;
	createdUserIds = [];
	return ids.map((id) => app.service('users').remove(id));
};

module.exports = (app, opt) => ({
	create: createTestUser(app, opt),
	cleanup: cleanup(app),
	info: createdUserIds,
	tempPinIds,
});

@@ -1,8 +1,90 @@
+const %7B registrationPinModel %7D = require('../../../../src/services/user/model');%0A%0A
 let crea
@@ -1097,22 +1097,32 @@
  = %5B%5D;%0A%09
-return
+const promises =
  ids.map
@@ -1164,16 +1164,150 @@
 e(id));%0A
+%09promises.push(%0A%09%09registrationPinModel.deleteMany(%7B _id: %7B $in: tempPinIds.map((p) =%3E p._id) %7D %7D),%0A%09);%0A%09return Promise.all(promises);%0A
 %7D;%0A%0Amodu

clear pins for new method