Skip to content

Commit

Permalink
Update env variable naming and add docs for createIdToken
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffplays2005 committed Oct 5, 2024
1 parent 46ca353 commit ff59a57
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/update_google_sheet_members.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}

Expand Down
17 changes: 11 additions & 6 deletions server/tooling/update-google-sheet-members.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 })
Expand Down

0 comments on commit ff59a57

Please sign in to comment.