Nombre de usuario agregado al sendemail
This commit is contained in:
@@ -37,6 +37,7 @@ build/Release
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
./.env
|
||||
scratch/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
+15
-8
@@ -2,6 +2,7 @@ const symbols = require('log-symbols');
|
||||
const generator = require('generate-password');
|
||||
const admin = require('../server/models/tablas/Admin');
|
||||
const bcrypt = require('bcrypt');
|
||||
const colors = require('colors');
|
||||
|
||||
const send = require('gmail-send')({
|
||||
user: process.env.EMAIL,
|
||||
@@ -11,13 +12,17 @@ const send = require('gmail-send')({
|
||||
|
||||
const emails = [
|
||||
'alfredo.lima@acatlan.unam.mx',
|
||||
'312047278@pcpuma.acatlan.unam.mx'
|
||||
'312047278@pcpuma.acatlan.unam.mx',
|
||||
'enrique.mg.cd@gmail.com'
|
||||
];
|
||||
|
||||
emails.forEach(async(email, index) => {
|
||||
const nombres = [
|
||||
'Alfredo Lima',
|
||||
'José Alfredo',
|
||||
'Enrique Maquinola'
|
||||
]
|
||||
|
||||
// Para pruebas
|
||||
await admin.sync({ force: true });
|
||||
emails.forEach(async(email, index) => {
|
||||
|
||||
let tempPass = generator.generate({
|
||||
length: 8,
|
||||
@@ -26,15 +31,17 @@ emails.forEach(async(email, index) => {
|
||||
exclude: `"`,
|
||||
strict: true
|
||||
});
|
||||
console.log(symbols.info, `Creating user ${email}...`);
|
||||
|
||||
console.log(symbols.info, `Creating user ${email}...`.blue.bold);
|
||||
let tempUser = await admin.create({
|
||||
name: email,
|
||||
userName: nombres[index],
|
||||
password: bcrypt.hashSync(tempPass, 10),
|
||||
isAdmin: false
|
||||
});
|
||||
if (!tempUser)
|
||||
return console.log(symbols.error, 'Error creating user. Exiting.');
|
||||
console.log(`Sending email to ${email}`);
|
||||
return console.log(symbols.error, 'Error creating user.'.red.bold);
|
||||
console.log(symbols.info, `Sending email to ${email}`.blue);
|
||||
await send({
|
||||
to: email,
|
||||
text: `Usuario: ${email}\nContraseña: ${tempPass}\nSaludos.`
|
||||
@@ -42,7 +49,7 @@ emails.forEach(async(email, index) => {
|
||||
async(err, res, resFull) => {
|
||||
if (err)
|
||||
return console.log(symbols.error, err);
|
||||
console.log(symbols.success, 'User created. Email sent.');
|
||||
console.log(symbols.success, 'User created. Email sent.'.green.bold);
|
||||
});
|
||||
|
||||
})
|
||||
+1
-1
@@ -1 +1 @@
|
||||
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkQWRtaW4iOjIsIm5hbWUiOiJhbGltYSIsInBhc3N3b3JkIjoiJDJiJDEwJEVXNjZHdUpYekVXWnFyNlNnYms2ME9wZ0JzZ25qTVZORnU1ZG1ScjJKZ1J5MEttOVE4QS5TIiwiaXNBZG1pbiI6dHJ1ZSwiY3JlYXRlZEF0IjoiMjAyMC0wOC0yMlQxODo1NjoxNS4wMDBaIiwidXBkYXRlZEF0IjoiMjAyMC0wOC0yMlQxODo1NjoxNS4wMDBaIn0sImlhdCI6MTU5ODMwOTg0MCwiZXhwIjoxNTk4Mzk2MjQwfQ.t-Ud7PT2MRqJuvj9YTQMleBY-Dqzu9A5K-qI8e40uvk
|
||||
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkQWRtaW4iOjQsIm5hbWUiOiJhbGltYSIsInVzZXJOYW1lIjoiQWxmcmVkbyBMaW1hIiwicGFzc3dvcmQiOiIkMmIkMTAka2dFcmlRN1MwbGdsU0YzakdYZ0hEdXNIblNJbFh1T3pHc3JILjR1SGI3N1JLY1c1TUpELksiLCJpc0FkbWluIjp0cnVlLCJjcmVhdGVkQXQiOiIyMDIwLTA4LTI1VDE4OjQ2OjAwLjAwMFoiLCJ1cGRhdGVkQXQiOiIyMDIwLTA4LTI1VDE4OjQ2OjAwLjAwMFoifSwiaWF0IjoxNTk4NDA3MjQ4LCJleHAiOjE1OTg0OTM2NDh9.U0RSj2VLh-6px1LYsAVkGzuklTzJs9KXIaSmDYlWzJc
|
||||
Reference in New Issue
Block a user