~bigbes/lethe

e920ae88160cd00850dcf0e5e4d876e2afe8600a — Eugene Blikh a month ago be6e43e
web: prune lethe_auth_failures log to the 5-min window on insert
2 files changed, 7 insertions(+), 3 deletions(-)

M internal/server/web/dist/index.html
M web/src/routes/auth.callback.tsx
M internal/server/web/dist/index.html => internal/server/web/dist/index.html +1 -1
@@ 13,7 13,7 @@
      href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500;700&display=swap"
      rel="stylesheet"
    />
    <script type="module" crossorigin src="/assets/index-DEdJhFGo.js"></script>
    <script type="module" crossorigin src="/assets/index-Cjf6VAVm.js"></script>
    <link rel="stylesheet" crossorigin href="/assets/index-D-7MmxJh.css">
  </head>
  <body class="density-compact">

M web/src/routes/auth.callback.tsx => web/src/routes/auth.callback.tsx +6 -2
@@ 66,10 66,14 @@ function CallbackRoute(): React.JSX.Element {
        } catch {
          log = []
        }
        log.push(Date.now())
        const now = Date.now()
        // Prune entries outside the 5-minute window before appending so the
        // array can't grow unbounded across many failed reloads.
        log = log.filter(ts => ts > now - 300_000)
        log.push(now)
        localStorage.setItem(FAILURES_KEY, JSON.stringify(log))

        const { blocked: isBlocked } = countCallbackFailures(Date.now(), log)
        const { blocked: isBlocked } = countCallbackFailures(now, log)
        return isBlocked
      }