Refactor: Analyze and fix security issues
This commit is contained in:
@@ -14,7 +14,13 @@ export const useAdminData = () => {
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
// Check if user has admin permissions
|
||||
// ⚠️ CRITICAL SECURITY WARNING: CLIENT-SIDE ROLE VERIFICATION
|
||||
// This checks roles from localStorage which can be easily manipulated by attackers
|
||||
// For PRODUCTION, you MUST implement server-side role verification:
|
||||
// 1. Create a separate 'user_roles' table in database
|
||||
// 2. Verify roles on EVERY API endpoint in the backend
|
||||
// 3. Use Row Level Security (RLS) policies in Supabase
|
||||
// This client-side check is ONLY for UI/UX purposes, NOT for actual security
|
||||
const isAdmin = user?.role === 'admin' || user?.role === 'super_admin';
|
||||
const isSuperAdmin = user?.role === 'super_admin';
|
||||
|
||||
|
||||
@@ -11,7 +11,10 @@ export const useEmergencyData = () => {
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
// Check if user has emergency permissions
|
||||
// ⚠️ CRITICAL SECURITY WARNING: CLIENT-SIDE ROLE VERIFICATION
|
||||
// This checks roles from localStorage which can be manipulated by users
|
||||
// For PRODUCTION: Implement server-side verification with user_roles table and RLS
|
||||
// This is ONLY for UI/UX, NOT for actual security
|
||||
const isOfficer = user?.role === 'politur' || user?.role === 'admin' || user?.role === 'super_admin';
|
||||
const isAdmin = user?.role === 'admin' || user?.role === 'super_admin';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user