mirror of
https://github.com/FranP-code/inbox-negotiator.git
synced 2025-10-13 00:42:26 +00:00
- Updated Navbar component to include a link to the configuration page. - Added a new Settings icon and link for user configuration. - Improved user session handling and UI updates based on authentication state. feat: implement OnboardingDialog for user setup - Created OnboardingDialog component to guide users through initial setup. - Added functionality to collect additional email addresses during onboarding. - Integrated toast notifications for error handling during email addition. feat: extend Supabase admin functions for user management - Added functions to retrieve user IDs and full user information by email. - Implemented error handling and logging for database operations. feat: update Supabase schema with new user features - Created new tables: user_profiles, additional_emails, and email_processing_usage. - Enabled Row Level Security (RLS) on new tables with appropriate policies. - Added triggers and functions for automatic user profile creation and email usage tracking. feat: create public users table for simplified access - Established a public.users table to mirror relevant auth.users data. - Implemented triggers to automatically populate public.users upon user creation. - Set up RLS policies to restrict access to user data. chore: add configuration files for Supabase local development - Included .gitignore and config.toml for local Supabase setup. - Configured email testing server and other development settings. feat: add configuration page for user settings - Created configuration.astro page to manage user settings. - Integrated AuthGuard to protect the configuration route.
42 lines
1.4 KiB
PL/PgSQL
42 lines
1.4 KiB
PL/PgSQL
-- Create a public users table that mirrors relevant auth.users data
|
|
-- This avoids the need for SECURITY DEFINER functions
|
|
|
|
-- Create the public users table
|
|
CREATE TABLE public.users (
|
|
id UUID REFERENCES auth.users NOT NULL PRIMARY KEY,
|
|
email TEXT NOT NULL,
|
|
created_at TIMESTAMPTZ DEFAULT NOW() NOT NULL
|
|
);
|
|
|
|
-- Create indexes for performance
|
|
CREATE INDEX idx_users_email ON public.users(email);
|
|
|
|
-- Create RLS policies for the users table
|
|
ALTER TABLE public.users ENABLE ROW LEVEL SECURITY;
|
|
|
|
-- Users can only read their own data
|
|
CREATE POLICY "Users can view own profile" ON public.users
|
|
FOR SELECT USING (auth.uid() = id);
|
|
|
|
-- Create a function to handle new user creation
|
|
CREATE OR REPLACE FUNCTION public.handle_new_user_add_public_users()
|
|
RETURNS trigger AS $$
|
|
BEGIN
|
|
INSERT INTO public.users (id, email, created_at)
|
|
VALUES (new.id, new.email, new.created_at);
|
|
RETURN new;
|
|
END;
|
|
$$ LANGUAGE plpgsql SECURITY DEFINER;
|
|
|
|
-- Create trigger to automatically create public.users record when auth.users is created
|
|
-- Drop existing trigger if it exists
|
|
DROP TRIGGER IF EXISTS on_auth_user_created_add_public_users ON auth.users;
|
|
|
|
CREATE TRIGGER on_auth_user_created_add_public_users
|
|
AFTER INSERT ON auth.users
|
|
FOR EACH ROW EXECUTE PROCEDURE public.handle_new_user_add_public_users();
|
|
|
|
-- Grant necessary permissions
|
|
GRANT SELECT ON public.users TO authenticated;
|
|
GRANT SELECT ON public.users TO anon;
|