Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add webhook callback to auth helper libraries #1216

Open
scotttrinh opened this issue Feb 25, 2025 · 0 comments
Open

Add webhook callback to auth helper libraries #1216

scotttrinh opened this issue Feb 25, 2025 · 0 comments

Comments

@scotttrinh
Copy link
Collaborator

We can validate the shape, verify the signature (if present), and present the developer with a nice API like:

type WebhookEvent =
  | EmailVerificationRequestedEvent
  | PasswordResetRequestedEvent;

// in `createAuthRouteHandlers`
async onWebhook(data: WebhookEvent) {
  switch (data.event_type) {
    case "EmailVerificationRequested": {
      await emails.sendVerification(data.email, data.verification_token);
      return;
    }
    case "PasswordResetRequested": {
      await emails.sendPasswordReset(data.email, data.reset_token);
      return;
    }
}

For Next.js we could even automatically wrap this in after so it doesn't block sending the webhook response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant