admin 管理员组文章数量: 1086019
When I'm creating a user via the Supabase authentication system, everything goes well untill i try to create this trigger:
This is my public.users table:
id (uuid, primary key, default value: gen_random_uuid())
created_at (timestampz, default: now())
firstname (text, default NULL)
lastname (text, default NULL)
email (text, default NULL)
auth_id (uuid, foreign key (auth_id -> auth.users.id), default value auth.uid())
None of the columns are nullable!
RLS for this public.users table (for insert):
permissive,
alter policy "Enable insert for authenticated users only"
on "public"."users"
to authenticated
with check (
true
);
Function: handle_new_confirmed_user:
begin
-- Insert a new row in public.users only if it doesn't exist
insert into public.users (auth_id, firstname, lastname, email)
values (new.id, new.raw_user_meta_data->>'firstName', new.raw_user_meta_data->>'lastName', new.email)
on conflict (auth_id) do nothing; -- Prevents duplicate entries
return new;
end;
trigger (on auth schema, table users): on_auth_user_confirmed:
enabled mode: always
condition: ((old.email_confirmed_at IS NULL) AND (new.email_confirmed_at IS NOT NULL))
function: handle_new_confirmed_user
events: after update
orientation: row
raw_user_meta_data upon creation:
{
"sub": "4a78b921-e556-4f33-99fb-ac4a8217c9af",
"email": "[email protected]",
"lastName": "Doe",
"firstName": "John",
"email_verified": false,
"phone_verified": false
}
I tried relaxing the RSL (did nothing), creating the user upon auth creation instead of after email confirmation (did nothing). I always get the error: http://localhost:3000/error?message=Error%20confirming%20user
The fault is certainly in the supabase backend and not in the code. Any help much appreciated!
本文标签: sqlWhy isn’t this (supabase) trigger workingStack Overflow
版权声明:本文标题:sql - Why isn’t this (supabase) trigger working? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744046612a2524237.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论