mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 18:52:06 +00:00
Implement authentication using Passport.js
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import argon2 from 'argon2';
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import { faker } from '@faker-js/faker';
|
||||
import DBClient from '../../DBClient';
|
||||
@@ -9,12 +10,19 @@ interface CreateNewUsersArgs {
|
||||
const createNewUsers = async ({ numberOfUsers }: CreateNewUsersArgs) => {
|
||||
const prisma = DBClient.instance;
|
||||
const userPromises = [];
|
||||
|
||||
const hashedPasswords = await Promise.all(
|
||||
Array.from({ length: numberOfUsers }, () => argon2.hash(faker.internet.password())),
|
||||
);
|
||||
|
||||
// eslint-disable-next-line no-plusplus
|
||||
for (let i = 0; i < numberOfUsers; i++) {
|
||||
const firstName = faker.name.firstName();
|
||||
const lastName = faker.name.lastName();
|
||||
const username = `${firstName[0]}.${lastName}`;
|
||||
const email = faker.internet.email(firstName, lastName, 'example.com');
|
||||
const username = `${firstName[0]}.${lastName}.${i}`;
|
||||
const email = faker.internet.email(firstName, lastName + i, 'example.com');
|
||||
|
||||
const hash = hashedPasswords[i];
|
||||
const dateOfBirth = faker.date.birthdate({ mode: 'age', min: 19 });
|
||||
const createdAt = faker.date.past(1);
|
||||
userPromises.push(
|
||||
@@ -26,6 +34,7 @@ const createNewUsers = async ({ numberOfUsers }: CreateNewUsersArgs) => {
|
||||
username,
|
||||
dateOfBirth,
|
||||
createdAt,
|
||||
hash,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user