- mappa iniziale

- fix PATCH /chval Json Injections: era possibile cambiare la password !
- ogni giorno sblocca la lista di chi chiede troppe richieste di recupero password.
This commit is contained in:
Surya Paolo
2024-03-21 21:22:57 +01:00
parent 3e0d0bf018
commit bd95e4457f
6 changed files with 77 additions and 21 deletions

View File

@@ -413,7 +413,7 @@ async function mycron() {
}
async function mycron_30min() {
for (const app of tools.getApps()) {
for (const app of await tools.getApps()) {
let enablecrontab = false;
enablecrontab = await Settings.getValDbSettings(app.idapp,
@@ -425,6 +425,29 @@ async function mycron_30min() {
}
}
async function mycron_everyday() {
try {
const { User } = require('./models/user');
const arrapps = await tools.getApps();
for (const app of arrapps) {
// Azzera le richieste di password:
const usersblocked = await User.find({ idapp: app.idapp, retry_pwd: { $exists: true, $gte: 29 } }).lean();
for (const user of usersblocked) {
await User.findOneAndUpdate({ _id: user._id }, { $set: { retry_pwd: 20 } });
let text = `⚠️⚠️⚠️ L\'utente ${user.username} (${user.name} ${user.surname}) viene sbloccato dal numero massimo di tentativi di richiesta password!\nTelerlo d\'occhio !\n@${user.profile.username_telegram}`;
await telegrambot.sendMsgTelegramToTheAdminAllSites(text, false);
}
}
} catch (e) {
console.error('mycron_everyday: ', e);
}
}
function testmsgwebpush() {
const { User } = require('./models/user');
@@ -452,7 +475,7 @@ function testmsgwebpush() {
cron.schedule('*/1 * * * *', () => {
// console.log('Running Cron Job');
// if (!process.env.DEBUG) {
mycron();
mycron();
// }
});
@@ -463,6 +486,11 @@ cron.schedule('*/60 * * * *', async () => {
}
});
// Cron every 21:00 (1 volta al giorno)
cron.schedule('0 21 * * *', async () => {
mycron_everyday();
});
// mycron_30min();
// tools.writelogfile('test', 'prova.txt');
@@ -489,6 +517,7 @@ async function resetProcessingJob() {
async function inizia() {
try {
mycron_everyday();
if (process.env.NODE_ENV === 'development') {
await telegrambot.sendMsgTelegram(tools.FREEPLANET,