20 lines
813 B
JavaScript
20 lines
813 B
JavaScript
const { faker } = require('@faker-js/faker');
|
|
|
|
function createIdentity() {
|
|
const firstName = faker.name.firstName().replace('\'', '');
|
|
const lastName = faker.name.lastName().replace('\'', '');
|
|
const birthDate = faker.date.between('1960-01-01', '2004-12-31');
|
|
const email = firstName + '.' + lastName + '@aostia.org';
|
|
return { first_name: firstName, last_name: lastName, birth_date: birthDate, email: email, password: generatePassword(12), address: faker.address.streetAddress() };
|
|
}
|
|
|
|
function generatePassword(length) {
|
|
const charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_+=~';
|
|
let password = '';
|
|
for (let i = 0; i < length; i++) {
|
|
password += charset.charAt(Math.floor(Math.random() * charset.length));
|
|
}
|
|
return password;
|
|
}
|
|
|
|
module.exports = { createIdentity }; |