Commit b05a5b9d authored by Vytor Calixto's avatar Vytor Calixto 👾

Merge branch 'release_v1.7.0'

Merge !155
parents f0c1f58d 4fe67c14
Pipeline #18424 failed with stage
in 6 minutes and 57 seconds
......@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## 1.7.0 - 2018-09-20
### Changed
- Fix return string in contract type id 1
- Fix out of school route
- Fix pib-per-capita route
- Fix filters in infrastructure route
- Remove filters in transport route
## 1.6.1 - 2018-08-23
# Changed
- Fix return json name in transport route
......
module.exports = function citySize(id) {
switch (id) {
case 1:
return 'até 5000';
return '0 - 5000';
case 2:
return '5001 - 10000';
case 3:
......
module.exports = function idhmLevel(id) {
module.exports = function contractType(id) {
switch (id) {
case 1:
return 'Concursado/Efetivo/Estavél';
return 'Concursado/Efetivo/Estável';
case 2:
return 'Contrato temporário';
case 3:
......
......@@ -76,6 +76,8 @@ const dailyChargeAmount = require(`${libs}/routes/dailyChargeAmount`);
const cub = require(`${libs}/routes/cub`);
const classCount = require(`${libs}/routes/classCount`);
const portalMecInep = require(`${libs}/routes/portalMecInep`);
......@@ -119,6 +121,7 @@ api.use('/transport', transport);
api.use('/cub', cub);
api.use('/auxiliar', auxiliar);
api.use('/verify_teacher', verifyTeacher);
api.use('/class_count', classCount);
api.use('/portal_mec_inep', portalMecInep);
module.exports = api;
......@@ -298,27 +298,39 @@ classCountApp.get('/source', (req, res, next) => {
next();
}, query, response('source'));
function mediaCalc(response) {
let obj = [];
response.forEach((result) => {
let newObj = {};
let keys = Object.keys(result);
keys.forEach((key) => {
if(key !== "total_classes" && key !== "total_enrollment")
newObj[key] = result[key]
})
newObj.total = result.total_enrollment / result.total_classes;
obj.push(newObj);
// Se a dimensão obrigatória do LDE (etapa de ensino) possui alguma etapa sem nenhum valor, então é criado um objeto
// com média 0.0 e é inserido no resultado. Usada para não quebrar a sequência de etapas na tabela do LDE.
function addNullFields(result) {
const firstYear = result[0].year;
var obj = result.filter(res => res.year == firstYear);
var prevFirstDimId = obj[0];
obj.forEach((d) => {
if((d["education_level_mod_id"] > prevFirstDimId["education_level_mod_id"]) && (prevFirstDimId["education_level_mod_id"] != 10) &&
(d["education_level_mod_id"] != prevFirstDimId["education_level_mod_id"] + 1)) {
let newObj = {};
Object.keys(prevFirstDimId).forEach((key) => {
newObj[key] = prevFirstDimId[key];
});
newObj.education_level_mod_id = d["education_level_mod_id"] - 1;
newObj.education_level_mod_name = id2str.educationLevelMod(d["education_level_mod_id"] - 1);
newObj.average = 0.0;
result.splice(result.indexOf(prevFirstDimId) + 1, 0, newObj);
}
prevFirstDimId = d;
});
return(obj);
}
// LDE
classCountApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
// Faz a consulta do número de alunos pelas dimensões
if(("education_level_mod" in req.dims) || ("education_level_mod" in req.filter)) {
req.sql.field('COUNT(turma.id)', 'total_classes')
.field('SUM(turma.num_matricula)', 'total_enrollment')
.field("'Brasil'", 'name')
req.sql.field("'Brasil'", 'name')
.field('turma.ano_censo', 'year')
.field('AVG(turma.num_matricula)', 'average')
.field('MEDIAN(turma.num_matricula)', 'median')
.field('STDDEV_POP(turma.num_matricula)', 'stddev')
.field('QUANTILE(turma.num_matricula, 0.25)', 'first_qt')
.field('QUANTILE(turma.num_matricula, 0.75)', 'third_qt')
.from('turma')
.group('turma.ano_censo')
.order('turma.ano_censo')
......@@ -332,75 +344,116 @@ classCountApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
});
}
}, rqf.build(), query, id2str.transform(), (req, res, next) => {
req.partial = req.result;
req.resetSql();
req.dims = {};
req.filter = {};
req.sql.field('COUNT(turma.id)', 'total_classes')
.field('SUM(turma.num_matricula)', 'total_enrollment')
.field("'Brasil'", 'name')
.field('turma.ano_censo', 'year')
.from('turma')
.group('turma.ano_censo')
.order('turma.ano_censo')
.where('turma.tipo_turma_id = 0 AND turma.etapas_mod_ensino_segmento_id >= 1 AND turma.etapas_mod_ensino_segmento_id <= 10');
next();
}, query, addMissing(rqf), id2str.transform(), (req, res, next) => {
const classCount = mediaCalc(req.partial);
const yearClassCount = mediaCalc(req.result);
req.result = classCount;
yearClassCount.forEach((result) => {
let obj = {};
obj = result;
obj.label = "total_year_media";
req.result.push(obj);
})
req.partial = [];
// Caso tenha apenas uma dimensão, o indicador possuirá uma linha de total
if((req.dims) && (req.dims.size == 1)) {
req.partial = req.result;
// A linha de total deverá conter o valor total do ano que está no banco de dados, então usa o mesmo filtro de anos da consulta anterior
let yearFilter = {};
if("min_year" in req.filter)
yearFilter.min_year = req.filter.min_year;
if("max_year" in req.filter)
yearFilter.max_year = req.filter.max_year;
// Faz a consulta sem dimensões, do total do(s) ano(s) escolhido(s)
req.resetSql();
req.dims = {};
req.filter = yearFilter;
req.sql.field("'Brasil'", 'name')
.field('turma.ano_censo', 'year')
.field('AVG(turma.num_matricula)', 'average')
.field('MEDIAN(turma.num_matricula)', 'median')
.field('STDDEV_POP(turma.num_matricula)', 'stddev')
.field('QUANTILE(turma.num_matricula, 0.25)', 'first_qt')
.field('QUANTILE(turma.num_matricula, 0.75)', 'third_qt')
.from('turma')
.group('turma.ano_censo')
.order('turma.ano_censo')
.where('turma.tipo_turma_id = 0 AND turma.etapas_mod_ensino_segmento_id >= 1 AND turma.etapas_mod_ensino_segmento_id <= 10');
}
next();
}, rqf.build(), query, addMissing(rqf), id2str.transform(), (req, res, next) => {
// Se tem apenas uma dimensão
if(req.partial.length > 0) {
const yearClassCount = req.result;
req.result = req.partial;
// Como a linha de total deve aparecer em um caso específico, ela é adicionada junto com a dimensão obrigatória
yearClassCount.forEach((result) => {
let obj = {};
obj = result;
obj.education_level_mod_name = "Total";
req.result.push(obj);
})
}
// Caso tenha mais de uma dimensão, retorna a consulta só pelas dimensões, sem linha de total
else
addNullFields(req.result);
next();
}, response('class_count'));
// SimCAQ
classCountApp.get('/count', rqf.parse(), rqf.build(), (req, res, next) => {
req.sql.field('COUNT(turma.id)', 'total_classes')
.field('SUM(turma.num_matricula)', 'total_enrollment')
.field("'Brasil'", 'name')
req.sql.field("'Brasil'", 'name')
.field('turma.ano_censo', 'year')
.field('AVG(turma.num_matricula)', 'average')
.field('MEDIAN(turma.num_matricula)', 'median')
.field('STDDEV_POP(turma.num_matricula)', 'stddev')
.field('QUANTILE(turma.num_matricula, 0.25)', 'first_qt')
.field('QUANTILE(turma.num_matricula, 0.75)', 'third_qt')
.from('turma')
.group('turma.ano_censo')
.order('turma.ano_censo')
.where('turma.tipo_turma_id = 0 AND turma.dependencia_adm_id <= 3 AND ((turma.etapa_resumida >= 1 AND turma.etapa_resumida <= 7) OR turma.etapa_resumida = 99)');
next();
}, query, id2str.transform(), (req, res, next) => {
}, rqf.build(), query, id2str.transform(), (req, res, next) => {
req.partial = [];
if(Object.keys(req.dims).length > 0 || Object.keys(req.filter).length > 0) {
if((req.dims) && (req.dims.size == 1)) {
req.partial = req.result;
// Se a consulta anterior selecionou dimensão:
// Considera apenas os anos escolhidos na consulta anterior para contar o número total de alunos
let yearFilter = {};
if("min_year" in req.filter)
yearFilter.min_year = req.filter.min_year;
if("max_year" in req.filter)
yearFilter.max_year = req.filter.max_year;
req.resetSql();
req.dims = {};
req.filter = {};
req.sql.field('COUNT(turma.id)', 'total_classes')
.field('SUM(turma.num_matricula)', 'total_enrollment')
.field("'Brasil'", 'name')
req.filter = yearFilter;
req.sql.field("'Brasil'", 'name')
.field('turma.ano_censo', 'year')
.field('AVG(turma.num_matricula)', 'average')
.field('MEDIAN(turma.num_matricula)', 'median')
.field('STDDEV_POP(turma.num_matricula)', 'stddev')
.field('QUANTILE(turma.num_matricula, 0.25)', 'first_qt')
.field('QUANTILE(turma.num_matricula, 0.75)', 'third_qt')
.from('turma')
.group('turma.ano_censo')
.order('turma.ano_censo')
.where('turma.tipo_turma_id = 0 AND turma.dependencia_adm_id <= 3 AND ((turma.etapa_resumida >= 1 AND turma.etapa_resumida <= 7) OR turma.etapa_resumida = 99)');
}
next();
}, query, addMissing(rqf), id2str.transform(), (req, res, next) => {
}, rqf.build(), query, addMissing(rqf), id2str.transform(), (req, res, next) => {
// Se possui apenas uma dimensão
if(req.partial.length > 0) {
const classCount = mediaCalc(req.partial);
const yearClassCount = mediaCalc(req.result);
req.result = classCount;
const yearClassCount = req.result;
req.result = req.partial;
// Adiciona os totais por anos ao fim da consulta
// Como esse tipo de total é específico desse indicador, um label foi adicionado para indicar
yearClassCount.forEach((result) => {
let obj = {};
obj = result;
obj.label = "total_year_media";
obj = result;
obj.label = "total_year_average";
req.result.push(obj);
})
}
else {
const classCount = mediaCalc(req.result);
req.result = classCount;
}
// Caso tenha mais de uma dimensão, retorna a consulta só pelas dimensões, sem linha de total (req.result)
next();
}, response('class_count'));
......
......@@ -404,7 +404,11 @@ dailyChargeAmountApp.get('/average', rqf.parse(), rqf.build(), (req, res, next)
req.sql.from('turma')
.field('turma.ano_censo', 'year')
.field('turma.etapas_mod_ensino_segmento_id', 'education_level_mod_id')
.field('AVG(turma.duracao_turma)/60.0', 'total')
.field('AVG(turma.duracao_turma)/60.0', 'average_class_duration')
.field('MEDIAN(turma.duracao_turma)/60.0', 'median_class_duration')
.field('STDDEV_POP(turma.duracao_turma)/60.0', 'std_class_duration')
.field('QUANTILE(turma.duracao_turma, 0.25)/60.0', 'fstqt_class_duration')
.field('QUANTILE(turma.duracao_turma, 0.75)/60.0', 'thdqt_class_duration')
.group('turma.ano_censo')
.group('turma.etapas_mod_ensino_segmento_id')
.order('turma.ano_censo')
......@@ -419,21 +423,6 @@ dailyChargeAmountApp.get('/average', rqf.parse(), rqf.build(), (req, res, next)
}
next();
}, query, addMissing(rqf), (req, res, next) => {
function sliced(object) {
return object['education_level_mod_id'] > 4;
}
if ('period' in req.filter || 'period' in req.dims) {
req.filter['period'].forEach((element) => {
if (element == '3')
req.result = req.result.filter(sliced);
});
}
next();
}, id2str.transform(), response('turma'));
}, query, addMissing(rqf), id2str.transform(), response('turma'));
module.exports = dailyChargeAmountApp;
......@@ -67,19 +67,26 @@ infrastructureApp.get('/rural_location', (req, res, next) => {
}, response('rural_location'));
infrastructureApp.get('/adm_dependency', (req, res, next) => {
req.sql.from('dependencia_adm')
.field('id')
.field('nome', 'name')
.where('id <= 4');
req.result = [];
for(let i = 1; i <= 4; ++i) {
req.result.push({
id: i,
name: id2str.admDependency(i)
});
};
next();
}, query, response('adm_dependency'));
}, response('adm_dependency'));
infrastructureApp.get('/adm_dependency_detailed', (req, res, next) => {
req.sql.from('dependencia_adm_priv')
.field('id', 'id')
.field('nome', 'name');
req.result = [];
for(let i = 1; i <= 6; ++i) {
req.result.push({
id: i,
name: id2str.admDependencyPriv(i)
});
};
next();
}, query, response('adm_dependency_detailed'));
}, response('adm_dependency_detailed'));
rqf.addField({
name: 'filter',
......
......@@ -155,6 +155,7 @@ pibpercapitaApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
.group('ibge_pib.ano_censo')
.group('ibge_pib.pib_per_capita')
.order('ibge_pib.ano_censo')
console.log("CiTy")
} else {
req.sql.from('ibge_pib')
.field('SUM(ibge_pib.pib)/SUM(ibge_pib.populacao)', 'total')
......@@ -165,8 +166,13 @@ pibpercapitaApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
next();
}, query, (req, res, next) => {
req.result.forEach((i) => {
let value = i.total;
let value = parseFloat(i.total);
let isnum = /^\d+$/.test(value);
if (isnum == true) {
value = value.toFixed(2)
}
// console.log(i.total);
let res = value.toString().split(".");
//rounding decimal.
let decimal = Math.round(res[1].toString().substring(0,2) + (".") + res[1].toString().substring(2,3));
......
......@@ -41,7 +41,7 @@ populationApp.get('/years', (req, res, next) => {
populationApp.get('/city_size', (req, res, next) => {
req.result = [
{id: 1, name: "até 5000"},
{id: 1, name: "0 - 5000"},
{id: 2, name: "5001 - 10000"},
{id: 3, name: "10001 - 20000"},
{id: 4, name: "20001 - 50000"},
......
......@@ -425,16 +425,16 @@ infrastructureApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
req.queryIndex.allCourtyard = req.queryIndex.allSchools;
let haveCourtyard = allSchools.clone();
haveCourtyard.where('escola.patio_coberto = 1 OR escola.patio_descoberto = 1');
haveCourtyard.where('escola.patio = 2 OR escola.patio = 1');
req.queryIndex.haveCourtyard = req.querySet.push(haveCourtyard) - 1;
let needCourtyard = allSchools.clone();
needCourtyard.where('escola.patio_descoberto = 0 AND escola.patio_descoberto = 0');
needCourtyard.where('escola.patio = 1');
req.queryIndex.needCourtyard = req.querySet.push(needCourtyard) - 1;
// Cobertura do Pátio
let allCourtyardCoverage = allSchools.clone();
allCourtyardCoverage.where('escola.patio_coberto=0 AND escola.patio_descoberto = 1');
allCourtyardCoverage.where('escola.patio = 1');
req.queryIndex.allCourtyardCoverage = req.querySet.push(allCourtyardCoverage) - 1;
req.queryIndex.haveCourtyardCoverage = req.queryIndex.allCourtyardCoverage;
......
......@@ -373,14 +373,14 @@ transportApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
// Vans e Kombi
let goVansAndKombi = allTransports.clone();
goVansAndKombi.field('matricula.transporte_vans_kombi','use_transport_id')
goVansAndKombi.where('matricula.transporte_vans_kombi = 1 OR matricula.transporte_vans_kombi = 0');
goVansAndKombi.where('matricula.transporte_vans_kombi = 1');
goVansAndKombi.group('matricula.transporte_vans_kombi');
req.queryIndex.goVansAndKombi = req.querySet.push(goVansAndKombi) - 1;
// Micro
let goMicroBus = allTransports.clone();
goMicroBus.field('matricula.transporte_micro_onibus', 'use_transport_id')
goMicroBus.where('matricula.transporte_micro_onibus = 1 OR matricula.transporte_micro_onibus = 0');
goMicroBus.where('matricula.transporte_micro_onibus = 1');
goMicroBus.group('matricula.transporte_micro_onibus');
req.queryIndex.goMicroBus = req.querySet.push(goMicroBus) - 1;
......@@ -388,63 +388,63 @@ transportApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
// Ônibus
let goBus = allTransports.clone();
goBus.field("matricula.transporte_onibus", 'use_transport_id')
goBus.where('matricula.transporte_onibus = 1 OR matricula.transporte_onibus = 0');
goBus.where('matricula.transporte_onibus = 1');
goBus.group('matricula.transporte_onibus')
req.queryIndex.goBus = req.querySet.push(goBus) - 1;
// Bicicleta
let goBikes = allTransports.clone();
goBikes.field('matricula.transporte_bicicleta', 'use_transport_id')
goBikes.where('matricula.transporte_bicicleta = 1 OR matricula.transporte_bicicleta = 0');
goBikes.where('matricula.transporte_bicicleta = 1');
goBikes.group('matricula.transporte_bicicleta')
req.queryIndex.goBikes = req.querySet.push(goBikes) - 1;
// Tração Animal
let goAnimalTraction = allTransports.clone();
goAnimalTraction.field('matricula.transporte_animal', 'use_transport_id')
goAnimalTraction.where('matricula.transporte_animal = 1 OR matricula.transporte_animal = 0');
goAnimalTraction.where('matricula.transporte_animal = 1');
goAnimalTraction.group('matricula.transporte_animal')
req.queryIndex.goAnimalTraction = req.querySet.push(goAnimalTraction) - 1;
// Outro Veículo
let goOtherVehicle = allTransports.clone();
goOtherVehicle.field('matricula.transporte_outro', 'use_transport_id')
goOtherVehicle.where('matricula.transporte_outro = 1 OR matricula.transporte_outro = 0');
goOtherVehicle.where('matricula.transporte_outro = 1');
goOtherVehicle.group('matricula.transporte_outro')
req.queryIndex.goOtherVehicle = req.querySet.push(goOtherVehicle) - 1;
// Aquaviário/ Embarcação (capacidade até 5 alunos)
let goWaterway_5_Students = allTransports.clone();
goWaterway_5_Students.field('matricula.transporte_embar_0_5','use_transport_id')
goWaterway_5_Students.where('matricula.transporte_embar_0_5 = 1 OR matricula.transporte_embar_0_5 = 0');
goWaterway_5_Students.where('matricula.transporte_embar_0_5 = 1');
goWaterway_5_Students.group('matricula.transporte_embar_0_5')
req.queryIndex.goWaterway_5_Students = req.querySet.push(goWaterway_5_Students) - 1;
// Aquaviário/ Embarcação (capacidade de 5 até 15 alunos)
let goWaterway_15_Students = allTransports.clone();
goWaterway_15_Students.field('matricula.transporte_embar_5_15', 'use_transport_id')
goWaterway_15_Students.where('matricula.transporte_embar_5_15 = 1 OR matricula.transporte_embar_5_15 = 0');
goWaterway_15_Students.where('matricula.transporte_embar_5_15 = 1');
goWaterway_15_Students.group('matricula.transporte_embar_5_15')
req.queryIndex.goWaterway_15_Students = req.querySet.push(goWaterway_15_Students) - 1;
// Aquaviário/ Embarcação (capacidade de 15 até 35 alunos)r
let goWaterway_35_Students = allTransports.clone();
goWaterway_35_Students.field('matricula.transporte_embar_15_35', 'use_transport_id')
goWaterway_35_Students.where('matricula.transporte_embar_15_35 = 1 OR matricula.transporte_embar_15_35 = 0');
goWaterway_35_Students.where('matricula.transporte_embar_15_35 = 1');
goWaterway_35_Students.group('matricula.transporte_embar_15_35')
req.queryIndex.goWaterway_35_Students = req.querySet.push(goWaterway_35_Students) - 1;
// Aquaviário/ Embarcação (capacidade mais 35 alunos)
let goWaterwayMoreThan_35 = allTransports.clone();
goWaterwayMoreThan_35.field('matricula.transporte_embar_35', 'use_transport_id')
goWaterwayMoreThan_35.where('matricula.transporte_embar_35 = 1 OR matricula.transporte_embar_35 = 0');
goWaterwayMoreThan_35.where('matricula.transporte_embar_35 = 1');
goWaterwayMoreThan_35.group('matricula.transporte_embar_35')
req.queryIndex.goWaterwayMoreThan_35 = req.querySet.push(goWaterwayMoreThan_35) - 1;
// Trêm / Metrô
let goSubwayAndTrain = allTransports.clone();
goSubwayAndTrain.field('matricula.transporte_trem_metro', 'use_transport_id')
goSubwayAndTrain.where('matricula.transporte_trem_metro = 1 OR matricula.transporte_trem_metro = 0');
goSubwayAndTrain.where('matricula.transporte_trem_metro = 1');
goSubwayAndTrain.group('matricula.transporte_trem_metro')
req.queryIndex.goSubwayAndTrain = req.querySet.push(goSubwayAndTrain) - 1;
......@@ -463,8 +463,8 @@ transportApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
for (let i = 0; i < transport_match_0.length; i++) {
transport_match_0[i].use_transport_id = true;
transport_match.push(transport_match_0[i])
transport_match_1[i].use_transport_id = false;
transport_match.push(transport_match_1[i])
// transport_match_1[i].use_transport_id = false;
// transport_match.push(transport_match_1[i])
}
//modifica adicionando use_transport_id=false, com os mesmos valores
......@@ -472,8 +472,8 @@ transportApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
for (let i = 0; i < all_enrollment_match_0.length; i++) {
all_enrollment_match_0[i].use_transport_id = true;
all_enrollment_match.push(all_enrollment_match_0[i])
all_enrollment_match_1[i].use_transport_id = false;
all_enrollment_match.push(all_enrollment_match_1[i])
// all_enrollment_match_1[i].use_transport_id = false;
// all_enrollment_match.push(all_enrollment_match_1[i])
}
let public_transport = matchQueries(all_enrollment_match, req.result[req.queryIndex.allEnrollmentTransport]);
......
......@@ -141,76 +141,54 @@ userApp.post('/', (req, res, next) => {
admin: false
});
let emailAddress = req.body.email;
let origin = req.body.origin;
User.findOne({email: emailAddress}, (err, find)=> {
if(err) {
if (typeof req.body.password === 'undefined' || !req.body.password) {
res.statusCode = 400;
return res.json({errors: ["O campo senha é obrigatório"]});
} else {
user.save((err) => {
if(err) {
log.error(err);
let errors = [];
for(let errName in err.errors) {
errors.push(err.errors[errName].message);
}
log.error(errors);
res.statusCode = 400;
return res.json({err, errors});
} else if (find) {
if (find.origin != origin) {
res.statusCode = 400;
return res.json({errors:["Identificamos que esta conta já existe em outra plataforma.\n\nVocê pode realizar o login com a conta do SimCAQ ou criar uma conta nova com outros dados"]});
} else {
res.statusCode = 400;
return res.json({errors:["Identificamos que esta conta já existe nesta plataforma"]});
}
} else {
if (typeof req.body.password === 'undefined' || !req.body.password) {
res.statusCode = 400;
return res.json({errors: ["O campo senha é obrigatório"]});
} else {
user.save((err) => {
if(err) {
log.error(err);
let errors = [];
for(let errName in err.errors) {
errors.push(err.errors[errName].message);
}
log.error(errors);
res.statusCode = 400;
return res.json({err, errors});
}
}
// Create verification token
let verificationToken = new VerificationToken({
userId: user._id
});
// Create verification token
let verificationToken = new VerificationToken({
userId: user._id
});
verificationToken.createVerificationToken((err, token) => {
if(err) {
log.error(err);
return next(err);
}
let url = config.default.lde.url + '/verify';
let text = `Olá, ${user.name}, seja bem vindo/a ao Laboratório de Dados Educacionais.\n\nClique neste link para confirmar sua conta: ${url}/${token}`;
// Send confirmation email
let mailOptions = {
to: `"${user.name} <${user.email}>"`,
subject: "Confirme seu cadastro - Laboratório de Dados Educacionais",
text
}
email(mailOptions, (err, info) => {
if(err) {
log.error(err);
res.json({msg: 'User created'});
}
if(info) {
log.info(`Message ${info.messageId} sent: ${info.response}`);
log.info(`Usuário ${user.email} foi criado`);
}
res.json({msg: 'User created'});
});
});
});
verificationToken.createVerificationToken((err, token) => {
if(err) {
log.error(err);
return next(err);
}
let url = config.default.lde.url + '/verify';
let text = `Olá, ${user.name}, seja bem vindo/a ao Laboratório de Dados Educacionais.\n\nClique neste link para confirmar sua conta: ${url}/${token}`;
// Send confirmation email
let mailOptions = {
to: `"${user.name} <${user.email}>"`,
subject: "Confirme seu cadastro - Laboratório de Dados Educacionais",
text
}
email(mailOptions, (err, info) => {
if(err) {
log.error(err);
res.json({msg: 'User created'});
}
}
})
if(info) {
log.info(`Message ${info.messageId} sent: ${info.response}`);
log.info(`Usuário ${user.email} foi criado`);
}
res.json({msg: 'User created'});
});
});
});
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment