Skip to content

Commit

Permalink
chore: replace v1 auth package with identity
Browse files Browse the repository at this point in the history
  • Loading branch information
steveoh committed Feb 5, 2025
1 parent 0f2afe8 commit 3993689
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions functions/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { auth, logger } from 'firebase-functions/v1'; // v2 does not support auth triggers as of july/23
import { logger } from 'firebase-functions/v2';
import {
onDocumentUpdated,
onDocumentCreated,
Expand All @@ -8,6 +8,7 @@ import {
onObjectFinalized,
onObjectDeleted,
} from 'firebase-functions/v2/storage';
import { beforeUserCreated } from 'firebase-functions/v2/identity';
import { https } from 'firebase-functions/v2';
import { defineSecret } from 'firebase-functions/params';
import { safelyInitializeApp } from './firebase.js';
Expand Down Expand Up @@ -38,11 +39,11 @@ const config = safelyInitializeApp();
const sendGridApiKey = defineSecret('SENDGRID_API_KEY');

// Firebase authentication
export const onCreateUser = auth.user().onCreate(async (user) => {
export const onCreateUser = beforeUserCreated(async (event) => {
logger.debug('[auth::user::onCreate] importing createUser');
const createUser = (await import('./auth/onCreate.js')).createUser;

const result = await createUser(user);
const result = await createUser(event.data);

logger.debug('[auth::user::onCreate]', result);

Expand Down

0 comments on commit 3993689

Please sign in to comment.