diff --git a/auth/auth.controller.ts b/auth/auth.controller.ts index a56a71e9f..14a7cdfda 100644 --- a/auth/auth.controller.ts +++ b/auth/auth.controller.ts @@ -53,7 +53,7 @@ export function createPayload(user, authOrg, prof) { */ export async function findTokenData(username: number, organizacion: ObjectId) { const pAuth = AuthUsers.findOne({ usuario: username, 'organizaciones._id': organizacion }); - const pProfesional = Profesional.findOne({ documento: String(username) }, { nombre: true, apellido: true }); + const pProfesional = Profesional.findOne({ documento: String(username), habilitado: { $ne: false } }, { nombre: true, apellido: true }); const [auth, prof]: [any, any] = await Promise.all([pAuth, pProfesional]); if (auth) { const authOrganizacion = auth.organizaciones.find(item => String(item._id) === String(organizacion)); @@ -106,7 +106,7 @@ export async function getTokenPayload(token, userData) { export async function findUser(username) { const pAuth = AuthUsers.findOne({ usuario: username }); - const pProfesional = Profesional.findOne({ documento: username }, { matriculas: true, especialidad: true }); + const pProfesional = Profesional.findOne({ documento: username, habilitado: { $ne: false } }, { matriculas: true, especialidad: true }); const [auth, prof] = await Promise.all([pAuth, pProfesional]); if (auth) { return { diff --git a/jobs/actualizarAgendasJob.ts b/jobs/actualizarAgendasJob.ts index 53fcac8e5..0544b7f07 100644 --- a/jobs/actualizarAgendasJob.ts +++ b/jobs/actualizarAgendasJob.ts @@ -4,7 +4,7 @@ import moment = require('moment'); function run(done) { const fechaActualizar = moment(new Date()); const start = (moment(fechaActualizar).startOf('day').subtract(1, 'days').toDate() as any); - const end = (moment(fechaActualizar).endOf('day').toDate() as any); + const end = (moment(start).endOf('day').toDate() as any); Promise.all([ agendaCtrl.actualizarTiposDeTurno(), agendaCtrl.actualizarEstadoAgendas(start, end)