From 357061221f8d1b6306db60ef2b610f7adef579f9 Mon Sep 17 00:00:00 2001 From: Matchu Date: Sat, 2 Oct 2021 00:57:39 -0700 Subject: [PATCH] Use env vars for MySQL in export-users-to-auth0 Huh, oops, there are a _few_ reasons the user sync cron job hasn't been running correctly. I fixed some of the config in prod, but then discovered one more issue: the script prompts for an admin database password, so of _course_ it can't auto-run, lol. Instead, I've now created a `impress2020-util` account, with just a few permissions (but specifically the `openneo_id.users` permission that I _don't_ give the app!), and added the username and password to the secret .env file, both locally and in prod. (In this case, prod means the Linode VPS, not Vercel, because that's where our cron runs.) --- scripts/export-users-to-auth0.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/export-users-to-auth0.js b/scripts/export-users-to-auth0.js index b1a8bc5..9cadf98 100644 --- a/scripts/export-users-to-auth0.js +++ b/scripts/export-users-to-auth0.js @@ -35,11 +35,10 @@ const auth0 = new ManagementClient({ async function main() { const connectionsPromise = auth0.getConnections(); - const { user, password } = await inquirer.prompt([ - { name: "user", message: "MySQL admin user:" }, - { name: "password", type: "password" }, - ]); - const db = await connectToDb({ user, password }); + const db = await connectToDb({ + user: process.env.IMPRESS_MYSQL_SCRIPT_USER, + password: process.env.IMPRESS_MYSQL_SCRIPT_PASSWORD, + }); const connections = await connectionsPromise; const { connectionId } = await inquirer.prompt([