Skip to content

Commit

Permalink
fix(auth): fix non interactive auth and force token refresh for coord…
Browse files Browse the repository at this point in the history
…inator
  • Loading branch information
ctrlc03 committed Jul 10, 2023
1 parent b637b9e commit 0f4dfea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/actions/test/utils/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,8 @@ export const createMockUser = async (
if (!adminAuth) throw new Error("Admin auth instance is required to set a user as coordinator.")
await setCustomClaims(adminAuth, uid, { coordinator: true })
await sleep(2000)
// refresh the token.
await getCurrentFirebaseAuthUser(userApp)?.getIdToken(true)
}

return uid
Expand Down
4 changes: 2 additions & 2 deletions packages/phase2cli/src/commands/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,15 +467,15 @@ export const handleCircuitArtifactUploadToStorage = async (
* from Hermez's ceremony Phase 1 Reliable Setup Ceremony.
* @param cmd? <any> - the path to the ceremony setup file.
*/
const setup = async (cmd: { template?: string, token?: string}) => {
const setup = async (cmd: { template?: string, auth?: string}) => {
// Setup command state.
const circuits: Array<CircuitDocument> = [] // Circuits.
let ceremonyId: string = "" // The unique identifier of the ceremony.

const { firebaseApp, firebaseFunctions, firestoreDatabase } = await bootstrapCommandExecutionAndServices()

// Check for authentication.
const { user, providerUserId } = cmd.token ? await authWithToken(firebaseApp, cmd.token) : await checkAuth(firebaseApp)
const { user, providerUserId } = cmd.auth ? await authWithToken(firebaseApp, cmd.auth) : await checkAuth(firebaseApp)

// Preserve command execution only for coordinators.
if (!(await isCoordinator(user))) showError(COMMAND_ERRORS.COMMAND_NOT_COORDINATOR, true)
Expand Down

0 comments on commit 0f4dfea

Please sign in to comment.