I’m making a next js project, I’ve got supabase installed and working well for signup/login etc.
I’ve started creating functions, one to move details from auth.user table into a public.user table.
That wasn’t working so I made a logging table to check that I could take data from auth.users and insert into logging table as a auth.user is created.
This doesn’t work either.
The trigger and function, have at some times, run when I manually insert a new user into the auth table. Those users are unverified.
The users I’m making through the JS API are auto-verified (I took the need for verification off).
So it’s just a really confusing thing, I’ve been looking at it for hours and no idea why this is happening.
My code
CREATE TRIGGER handle_auth_user
AFTER INSERT ON auth.users
FOR EACH ROW
EXECUTE FUNCTION on_auth_user_created();
FUNCTION on_auth_user_created()
RETURNS TRIGGER AS $$
BEGIN
INSERT INTO logging (id)
VALUES (NEW.id);
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
In this function above ^ Everything works if I dont have anything in the function so for example, no insertions. A raised notice does work. But as soon as insertions happen the API JS doesnt allow me to add users. And most of the time, I’m not able to manually insert them.
Tried giving public access etc. Tried multiple different tables to insert into etc.
There is a youtube video that confirms this should work. I might have to start from scratch and try again but I’m super confused
I tried triggers and functions. Expecting when Auth.user created, an insertion into any table would be possible.
Made a new project, gave anon all privileges to the auth.users and to a logging table.
Tested using the anon role and could both insert into logging and read from auth.users. And the trigger and function would still fail.
Fred Miller is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1