Skip to content

send_email auth hook email_change does not contain token when anonymous users try to sign up using updateUser #2042

@Ruud14

Description

@Ruud14

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

It is basically the exact same issue as #1744,
however the patch there does not cover anonymous users.

When using a send_email auth hook and using .updateUser to convert an anonymous user into an authenticated user (as described here) the email_data in the auth hook does not contain any token data.

{
  token: "",
  token_hash: "<my token hash>",
  redirect_to: "<my redirect url>",
  email_action_type: "email_change",
  site_url: "<my site url>",
  token_new: "",
  token_hash_new: ""
}

When looking at the source code here it seems like this is because here there is a check for empty email. Since the user is anonymous the email is empty and we won't get into the ìf` block, resulting in the new otp not being set.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Create an anonymous user.
  2. Set up an email auth hook
  3. Try to upgrade the anonymous user to an authenticated user as described here
  4. There is no OTP token data in the email data.

Expected behavior

There is OTP token data in the email data.
Something like

{
  token: "",
  token_hash: "<my token hash>",
  redirect_to: "<my redirect url>",
  email_action_type: "email_change",
  site_url: "<my site url>",
  token_new: "123456",
  token_hash_new: ""
}

System information

  • supabase_flutter: ^2.9.0
  • gotrue v2.173.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions