From e0302e877dc028307b11cc3857f9d9953f03e8e0 Mon Sep 17 00:00:00 2001 From: Maxime Alza Date: Wed, 24 Jul 2024 22:23:07 +0200 Subject: [PATCH] Remove inactive user (more thant 1 year without connect) in cleanup --- translation-app-assessment/backend/cleanup/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/translation-app-assessment/backend/cleanup/index.js b/translation-app-assessment/backend/cleanup/index.js index b47cdd5..ef3a301 100644 --- a/translation-app-assessment/backend/cleanup/index.js +++ b/translation-app-assessment/backend/cleanup/index.js @@ -18,6 +18,9 @@ app.use(cookieParser()) app.disable('x-powered-by') require("dotenv"); const cors = require('cors'); +firebaseAdmin.initializeApp({ + credential: firebaseAdmin.credential.applicationDefault() +}); const corsOptions = { origin: process.env.FRONTEND_URL, @@ -363,7 +366,9 @@ async function createLanguage(isoCode, occurrences, average) { } async function deleteInactiveUsers() { + const auth = firebaseAdmin.auth(); + const oneYearAgo = Date.now() - 365 * 24 * 60 * 60 * 1000; try { let usersDeleted = 0;