Firebase Auth
Firebase creates accounts in the browser, so put the gate in a callable function and create the user there with the Admin SDK.
functions/src/signup.ts
import { onCall, HttpsError } from 'firebase-functions/v2/https';
import { getAuth } from 'firebase-admin/auth';
const call = (path: string, body: unknown) =>
fetch(`https://waitlistly.live/api/v1/${path}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${process.env.WAITLISTLY_SECRET_KEY}` },
body: JSON.stringify(body),
}).then((r) => r.json());
export const signUpWithInvite = onCall(async ({ data }) => {
const invite = await call('invites/verify', { code: data.inviteCode });
if (!invite.valid) throw new HttpsError('permission-denied', 'This invite is not valid or has expired.');
const user = await getAuth().createUser({ email: invite.email, password: data.password });
await call('activations', { code: data.inviteCode });
return { uid: user.uid };
});Then sign the user in on the client with signInWithEmailAndPassword.
Last updated on