diff --git a/.gitignore b/.gitignore index e8d04de..1846749 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,7 @@ build/Release node_modules/ jspm_packages/ ./.env +scratch/ # TypeScript v1 declaration files typings/ diff --git a/helpers/sendEmail.js b/helpers/sendEmail.js index 3734efd..59117fa 100644 --- a/helpers/sendEmail.js +++ b/helpers/sendEmail.js @@ -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); }); }) \ No newline at end of file diff --git a/scratch/token b/scratch/token index 7271d4b..12a9169 100644 --- a/scratch/token +++ b/scratch/token @@ -1 +1 @@ -eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkQWRtaW4iOjIsIm5hbWUiOiJhbGltYSIsInBhc3N3b3JkIjoiJDJiJDEwJEVXNjZHdUpYekVXWnFyNlNnYms2ME9wZ0JzZ25qTVZORnU1ZG1ScjJKZ1J5MEttOVE4QS5TIiwiaXNBZG1pbiI6dHJ1ZSwiY3JlYXRlZEF0IjoiMjAyMC0wOC0yMlQxODo1NjoxNS4wMDBaIiwidXBkYXRlZEF0IjoiMjAyMC0wOC0yMlQxODo1NjoxNS4wMDBaIn0sImlhdCI6MTU5ODMwOTg0MCwiZXhwIjoxNTk4Mzk2MjQwfQ.t-Ud7PT2MRqJuvj9YTQMleBY-Dqzu9A5K-qI8e40uvk \ No newline at end of file +eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkQWRtaW4iOjQsIm5hbWUiOiJhbGltYSIsInVzZXJOYW1lIjoiQWxmcmVkbyBMaW1hIiwicGFzc3dvcmQiOiIkMmIkMTAka2dFcmlRN1MwbGdsU0YzakdYZ0hEdXNIblNJbFh1T3pHc3JILjR1SGI3N1JLY1c1TUpELksiLCJpc0FkbWluIjp0cnVlLCJjcmVhdGVkQXQiOiIyMDIwLTA4LTI1VDE4OjQ2OjAwLjAwMFoiLCJ1cGRhdGVkQXQiOiIyMDIwLTA4LTI1VDE4OjQ2OjAwLjAwMFoifSwiaWF0IjoxNTk4NDA3MjQ4LCJleHAiOjE1OTg0OTM2NDh9.U0RSj2VLh-6px1LYsAVkGzuklTzJs9KXIaSmDYlWzJc \ No newline at end of file