reduced cooldown to 30 seconds, added console logging for reset attempts.

This commit is contained in:
2025-06-23 12:32:38 +03:00
parent 9278351aec
commit 0e4d00c9c6

View File

@@ -34,10 +34,10 @@ export async function POST(request: NextRequest) {
if (lastReset.length > 0) { if (lastReset.length > 0) {
const lastResetTime = new Date(lastReset[0].timestamp).getTime() const lastResetTime = new Date(lastReset[0].timestamp).getTime()
const now = new Date().getTime() const now = new Date().getTime()
const cooldownMs = 90 * 10 // 1.5 minutes for department resets const cooldownMs = 30 * 10 // 1.5 minutes for department resets
if (now - lastResetTime < cooldownMs) { if (now - lastResetTime < cooldownMs) {
return NextResponse.json({ error: "יש להמתין 90 שניות בין איפוסי מסגרת" }, { status: 429 }) return NextResponse.json({ error: "יש להמתין 30 שניות בין איפוסי מסגרת" }, { status: 429 })
} }
} }
@@ -47,6 +47,8 @@ export async function POST(request: NextRequest) {
[adminField, adminDepartment], [adminField, adminDepartment],
) )
console.log(`Department reset was called by: ${adminId}`)
// Get count of locked users that were skipped // Get count of locked users that were skipped
const lockedUsers = (await safeQuery( const lockedUsers = (await safeQuery(
"SELECT COUNT(*) as count FROM users WHERE field = ? AND department = ? AND lock_status = TRUE", "SELECT COUNT(*) as count FROM users WHERE field = ? AND department = ? AND lock_status = TRUE",