sipher/supabase/sql_snippets/Add public key to users.sql
Nixyi 8b27c6b140 Stable Release (I think)
Added all SQL scripts by using a python script to fetch them.

Also added a "About" page and a skeleton to the chat page.

Fixed the register function that was not setting the public_key on the database
2024-12-18 16:08:06 -03:00

1 line
No EOL
448 B
PL/PgSQL

ALTER TABLE public.users
ADD COLUMN IF NOT EXISTS public_key JSONB;
-- Function to update user's public key
CREATE
OR REPLACE FUNCTION public.update_user_public_key(
new_public_key JSONB
) RETURNS boolean AS $$
BEGIN
UPDATE public.users
SET public_key = new_public_key
WHERE uuid = auth.uid();
RETURN
FOUND;
END;
$$
LANGUAGE plpgsql SECURITY DEFINER;
GRANT EXECUTE ON FUNCTION public.update_user_public_key TO authenticated;