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.)
This commit is contained in:
Emi Matchu 2021-10-02 00:57:39 -07:00
parent 9b856a40b8
commit 357061221f

View file

@ -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([