Quellcode des ICON CRM (2)

This commit is contained in:
2026-09-14 16:55:32 +02:00
parent c8db64af7e
commit 0a597ae527
25 changed files with 5057 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
-- ============================================================
-- ICON CRM – Benutzerverwaltung (icon_users)
-- Dieses Skript einmalig in der Supabase SQL-Konsole ausführen.
-- ============================================================
-- 1. Tabelle erstellen (vorherige Tabelle löschen, falls vorhanden, um Schema-Konflikte zu vermeiden)
DROP TABLE IF EXISTS public.icon_users CASCADE;
CREATE TABLE public.icon_users (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
username text NOT NULL UNIQUE,
email text UNIQUE,
name text NOT NULL,
role text NOT NULL DEFAULT 'user' CHECK (role IN ('admin', 'user')),
password_hash text NOT NULL,
created_at timestamptz DEFAULT now()
);
-- 2. Row-Level-Security aktivieren
ALTER TABLE public.icon_users ENABLE ROW LEVEL SECURITY;
-- 3. Anon-Key Zugriff erlauben (die App nutzt den Anon-Key)
DROP POLICY IF EXISTS "Allow anon full access to icon_users" ON public.icon_users;
CREATE POLICY "Allow anon full access to icon_users"
ON public.icon_users
FOR ALL
TO anon
USING (true)
WITH CHECK (true);
-- 4. Admin-Passwort-Hash berechnen und einfügen.
-- SHA-256 von "Elonsucks69!" wird direkt von Postgres berechnet.
INSERT INTO public.icon_users (username, email, name, role, password_hash)
VALUES (
'Admin',
'admin@icon-experts.de',
'Admin User',
'admin',
encode(sha256('Elonsucks69!'::bytea), 'hex')
)
ON CONFLICT (username)
DO UPDATE SET password_hash = EXCLUDED.password_hash;
-- ============================================================
-- FERTIG! Tabelle bereit. Erster Login: Admin / Elonsucks69!
-- ============================================================