Güvenlik Doğrulaması,Login Logları

This commit is contained in:
2025-12-29 23:51:25 +03:00
parent 7d55ec93ae
commit 8ba8d2e05e
24 changed files with 1861 additions and 166 deletions

View File

@@ -0,0 +1,19 @@
-- Create a table to store OTP codes
CREATE TABLE IF NOT EXISTS public.auth_codes (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE NOT NULL,
code TEXT NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT timezone('utc'::text, now()) NOT NULL,
expires_at TIMESTAMP WITH TIME ZONE NOT NULL
);
-- Enable Row Level Security
ALTER TABLE public.auth_codes ENABLE ROW LEVEL SECURITY;
-- Allow users to see only their own codes
CREATE POLICY "Users can see their own codes" ON public.auth_codes
FOR SELECT USING (auth.uid() = user_id);
-- Allow server-side operations (Service Role will bypass RLS, but good to have)
CREATE POLICY "Users can insert their own codes" ON public.auth_codes
FOR INSERT WITH CHECK (auth.uid() = user_id);