@@ -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
163142export async function updateUser ( documento , nombre , apellido , password ) {
164143 return await AuthUsers . findOneAndUpdate (
0 commit comments