mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
Create location table for brewery post locations
This commit is contained in:
@@ -16,6 +16,9 @@ const createNewUsers = async ({ numberOfUsers }: CreateNewUsersArgs) => {
|
||||
Array.from({ length: numberOfUsers }, () => argon2.hash(faker.internet.password())),
|
||||
);
|
||||
|
||||
const takenEmails: string[] = [];
|
||||
const takenUsernames: string[] = [];
|
||||
|
||||
// eslint-disable-next-line no-plusplus
|
||||
for (let i = 0; i < numberOfUsers; i++) {
|
||||
const randomValue = crypto.randomBytes(10).toString('hex');
|
||||
@@ -24,6 +27,18 @@ const createNewUsers = async ({ numberOfUsers }: CreateNewUsersArgs) => {
|
||||
const username = `${firstName[0]}.${lastName}.${randomValue}`;
|
||||
const email = faker.internet.email(firstName, randomValue, 'example.com');
|
||||
|
||||
const usernameTaken = takenUsernames.includes(username);
|
||||
const emailTaken = takenEmails.includes(email);
|
||||
|
||||
if (usernameTaken || emailTaken) {
|
||||
i -= 1;
|
||||
// eslint-disable-next-line no-continue
|
||||
continue;
|
||||
}
|
||||
|
||||
takenEmails.push(email);
|
||||
takenUsernames.push(username);
|
||||
|
||||
const hash = hashedPasswords[i];
|
||||
const dateOfBirth = faker.date.birthdate({ mode: 'age', min: 19 });
|
||||
const createdAt = faker.date.past(1);
|
||||
|
||||
Reference in New Issue
Block a user