Skip to content

Commit e19a42b

Browse files
committed
fix - Corrección en la busqueda de derivaciones
1 parent b8338c0 commit e19a42b

5 files changed

Lines changed: 5 additions & 33 deletions

File tree

auth/auth.class.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,6 @@ export class Auth {
226226

227227
};
228228

229-
if (payload.organizacion.fechaVencimiento) {
230-
const now = new Date();
231-
const fechaVencimiento = new Date(payload.organizacion.fechaVencimiento);
232-
if (fechaVencimiento < now) {
233-
return next(403);
234-
}
235-
}
236229

237230
return next();
238231
} else {

auth/auth.controller.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ export function createPayload(user, authOrg, prof) {
6565
},
6666
profesional: prof && String(prof._id),
6767
permisos: [...user.permisosGlobales, ...authOrg.permisos],
68-
fechaVencimiento: authOrg.fechaVencimiento,
6968
feature: { ...(user.configuracion || {}) }
7069
};
7170
}
@@ -78,7 +77,6 @@ export async function findTokenData(username: number, organizacion: ObjectId) {
7877
const pProfesional = Profesional.findOne({ documento: String(username), habilitado: { $ne: false } }, { nombre: true, apellido: true });
7978
const [auth, prof]: [any, any] = await Promise.all([pAuth, pProfesional]);
8079
if (auth) {
81-
await checkAndInactivateExpired(auth);
8280
const authOrganizacion = auth.organizaciones.find(item => String(item._id) === String(organizacion));
8381
return {
8482
usuario: auth,
@@ -132,7 +130,6 @@ export async function findUser(username) {
132130
const pProfesional = Profesional.findOne({ documento: username, habilitado: { $ne: false } }, { matriculas: true, especialidad: true });
133131
const [auth, prof] = await Promise.all([pAuth, pProfesional]);
134132
if (auth) {
135-
await checkAndInactivateExpired(auth);
136133
return {
137134
user: auth,
138135
profesional: prof
@@ -141,24 +138,6 @@ export async function findUser(username) {
141138
return null;
142139
}
143140

144-
/**
145-
* Chequea las organizaciones del usuario e inactiva las que tienen fecha de vencimiento cumplida.
146-
* @param {any} user Instancia de AuthUsers
147-
*/
148-
export async function checkAndInactivateExpired(user) {
149-
let changed = false;
150-
const now = new Date();
151-
user.organizaciones.forEach(org => {
152-
if (org.activo && org.fechaVencimiento && org.fechaVencimiento < now) {
153-
org.activo = false;
154-
changed = true;
155-
}
156-
});
157-
if (changed) {
158-
user.audit(userScheduler);
159-
await user.save();
160-
}
161-
}
162141

163142
export async function updateUser(documento, nombre, apellido, password) {
164143
return await AuthUsers.findOneAndUpdate(

auth/schemas/authUsers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export interface IAuthUsers {
2323
nombre: string;
2424
}[];
2525
lastLogin: Date;
26-
fechaVencimiento?: Date;
2726
}[];
2827
lastLogin: Date;
2928
tipo?: String;

auth/schemas/permisos-organizaciones.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ export const PermisosOrganizacionesSchema = new Schema({
1111
_id: Types.ObjectId,
1212
nombre: String
1313
}],
14-
lastLogin: Date,
15-
fechaVencimiento: Date
14+
lastLogin: Date
1615
});
1716
PermisosOrganizacionesSchema.plugin(AuditPlugin);
1817

modules/centroOperativoMedico/derivaciones.routes.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ class DerivacionesResource extends ResourceBase {
3434
estrategia: {
3535
field: 'estrategiaAtencion.id',
3636
fn: (value) => {
37-
if (value === 'null') {
37+
if (!value || value === 'null') {
3838
return {
3939
$or: [
4040
{ estrategiaAtencion: null },
41-
{ estrategiaAtencion: { $exists: false } }
41+
{ estrategiaAtencion: { $exists: false } },
42+
{ 'estrategiaAtencion.id': { $exists: false } },
43+
{ 'estrategiaAtencion.id': null }
4244
]
4345
};
4446
}

0 commit comments

Comments
 (0)