1
0
mirror of https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git synced 2025-08-14 00:25:46 +02:00

Initial commit

This commit is contained in:
MoonTestUse1
2024-12-23 19:27:44 +06:00
commit e81df4c87e
4952 changed files with 1705479 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
/*
# Update Employee Table RLS Policies
1. Changes
- Drop existing RLS policies
- Create new policies for admin access
- Add policy for employee self-access
2. Security
- Enable RLS on employees table
- Admin can manage all employees
- Employees can view their own data
*/
-- Drop existing policies if they exist
DROP POLICY IF EXISTS "Admins can manage employees" ON employees;
DROP POLICY IF EXISTS "Employees can view own data" ON employees;
-- Enable RLS
ALTER TABLE employees ENABLE ROW LEVEL SECURITY;
-- Create admin policy for full access
CREATE POLICY "Admins can manage employees"
ON employees
FOR ALL
TO authenticated
USING (
auth.jwt() ->> 'email' = 'admin@example.com'
);
-- Create policy for employees to view their own data
CREATE POLICY "Employees can view own data"
ON employees
FOR SELECT
TO authenticated
USING (
id = auth.uid()
);