module.exports = async function(pg, users) { let adminUser for (const user of users) { const existing = await pg.user.findByEmail(user.email) if(existing) { console.warn(" Warning: duplicate user with email " + user.email) continue; } const newUser = await pg.user.import(user.email, user.password); if (user.emailConfirmed) { await pg.user.markEmailVerified(newUser.uuid) } if (user.isAdmin) { await pg.user.makeAdmin(newUser.uuid) } if (user.isAdmin && !adminUser) { adminUser = newUser; } const creationDate = new Date(parseInt(user._id.toString().slice(0,8), 16)*1000) await pg.user.updateRegistrationDate(newUser.uuid, creationDate, user.emailConfirmed) } if (!adminUser) { throw new Error("Unable to find importing admin") } return adminUser }