From ff59a570d038bb0c653966d49e316e57fb56d78c Mon Sep 17 00:00:00 2001 From: jeffplays2005 Date: Sat, 5 Oct 2024 22:37:47 +1300 Subject: [PATCH] Update env variable naming and add docs for createIdToken --- .../workflows/update_google_sheet_members.yml | 4 ++-- server/tooling/update-google-sheet-members.ts | 17 +++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/update_google_sheet_members.yml b/.github/workflows/update_google_sheet_members.yml index c37dd2d1..60dfb491 100644 --- a/.github/workflows/update_google_sheet_members.yml +++ b/.github/workflows/update_google_sheet_members.yml @@ -8,8 +8,8 @@ on: env: NEXT_PUBLIC_BACKEND_BASE_URL: ${{secrets.VITE_BACKEND_BASE_URL}} - GOOGLE_SPREADSHEET_ID: ${{secrets.GOOGLE_SPREADSHEET_ID}} - GOOGLE_SHEET_ID: ${{secrets.GOOGLE_SHEET_ID}} + MEMBERS_GOOGLE_SPREADSHEET_ID: ${{secrets.MEMBERS_GOOGLE_SPREADSHEET_ID}} + MEMBERS_GOOGLE_SHEET_ID: ${{secrets.MEMBERS_GOOGLE_SHEET_ID}} GOOGLE_SERVICE_ACCOUNT_JSON: ${{secrets.GOOGLE_SERVICE_ACCOUNT_JSON}} NEXT_PUBLIC_FIREBASE_API_KEY: ${{secrets.VITE_FIREBASE_API_KEY}} diff --git a/server/tooling/update-google-sheet-members.ts b/server/tooling/update-google-sheet-members.ts index 4643fefd..8dad71e5 100644 --- a/server/tooling/update-google-sheet-members.ts +++ b/server/tooling/update-google-sheet-members.ts @@ -9,8 +9,8 @@ dotenv.config() // Environment variables const BASE_URL = process.env.NEXT_PUBLIC_BACKEND_BASE_URL -const SPREADSHEET_ID = process.env.GOOGLE_SPREADSHEET_ID -const SHEET_ID = process.env.GOOGLE_SHEET_ID +const MEMBERS_GOOGLE_SPREADSHEET_ID = process.env.MEMBERS_GOOGLE_SPREADSHEET_ID +const MEMBERS_GOOGLE_SHEET_ID = process.env.MEMBERS_GOOGLE_SHEET_ID const API_KEY = process.env.NEXT_PUBLIC_FIREBASE_API_KEY const GOOGLE_SERVICE_ACCOUNT_JSON = process.env.GOOGLE_SERVICE_ACCOUNT_JSON const USER_ID = process.env.USER_ID @@ -110,9 +110,9 @@ async function updateGoogleSheet(auth: any, rows: any[]) { }) const request = { - spreadsheetId: SPREADSHEET_ID, + spreadsheetId: MEMBERS_GOOGLE_SPREADSHEET_ID, // Sheet id is something like "Sheet1" - range: SHEET_ID + "!A1", + range: MEMBERS_GOOGLE_SHEET_ID + "!A1", valueInputOption: "RAW", insertDataOption: "INSERT_ROWS", resource: { @@ -140,8 +140,8 @@ async function clearSheet(auth: any) { }) const request = { - spreadsheetId: SPREADSHEET_ID, - range: SHEET_ID + spreadsheetId: MEMBERS_GOOGLE_SPREADSHEET_ID, + range: MEMBERS_GOOGLE_SHEET_ID } try { await sheets.spreadsheets.values.clear(request) @@ -180,6 +180,11 @@ function mapUsers(users: CombinedUserData[]) { ]) } +/** + * Code from login-prod.ts to create admin jwt token + * @param uid - The user id to create the token for + * @returns The jwt token + */ const createIdToken = async (uid: string) => { try { await admin.auth().setCustomUserClaims(uid, { member: true, admin: true })