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

Internally inviteUserByEmail is not reading .data.custom_value when sending invitation email. #1370

Open
2 tasks done
flesicek opened this issue Jan 8, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@flesicek
Copy link

flesicek commented Jan 8, 2024

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

We have before insert trigger on top of the auth.users that is adding custom variables into raw_user_meta_data field. When the inviteUserByEmail function is triggered, Invite user email is sent, but {{ .Data.custom_variable }} is empty <- this is the bug

To Reproduce

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

  1. Create a before insert trigger on the auth.users table
  2. In the trigger function, set NEW.raw_user_meta_data['custom_variable'] = to_jsonb('Custom text'::text);
  3. In the Invite email template, add into body {{ .Data.custom_variable }}
  4. Trigger Supabase JS function inviteUserByEmail

Expected behavior

The invite email should have somewhere text "Custom text". But there will be nothing.

@flesicek flesicek added the bug Something isn't working label Jan 8, 2024
@kangmingtay
Copy link
Member

hi @flesicek, you can insert custom user metadata by passing a data object in the options field when you can inviteUserByEmail if you use supabase-js like:

const { error } = await supabase.auth.admin.inviteUserByEmail({ 
  email, 
  options: { 
    data: { 
      custom_variable: 'xxx' 
    }
  }
})

we currently don't support fetching the user record from the db after creating it which is why the before insert trigger is not being reflected when the email is being sent out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants