-
Notifications
You must be signed in to change notification settings - Fork 507
Open
Labels
bugSomething isn't workingSomething isn't working
Description
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
Supabase's "Add user" function in the "Authentication -> Users" tab overwrites any changes in the raw_user_meta_data
column from "before insert" triggers, when the option "Auto Confirm User?" is selected.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Start from a clean database
- Create the following trigger:
CREATE OR REPLACE FUNCTION public.poc_function()
RETURNS TRIGGER
LANGUAGE plpgsql
SECURITY DEFINER SET search_path = ''
AS $$
BEGIN
new."raw_user_meta_data" := (coalesce(new."raw_user_meta_data", '{}')::jsonb ||
jsonb_build_object('new_key', true));
RETURN new;
END;
$$;
CREATE OR REPLACE TRIGGER on_auth_user_created
BEFORE INSERT ON auth.users
FOR EACH ROW
EXECUTE FUNCTION public.poc_function();
- Create a new user from the "Authentication -> Users" tab, with the option "Auto Confirm User?" checked.
- Observe that this user only has the JSON
{email_verified": true}
in theraw_user_meta_data
column. - Create another user from the "Authentication -> Users" tab, with the option "Auto Confirm User?" unchecked.
- Observe that this user now has the JSON value
{"new_key": true}
in theraw_user_meta_data
column
Expected behavior
Creating a user with the option "Auto Confirm User" with the trigger above should create a new user with the column raw_user_meta_data
with the JSON value {email_verified": true, "new_key": true}
.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working