fix: remove service_role from ErrorLogPanel - use anon key + RLS
This commit is contained in:
parent
3934e6a872
commit
f4a4082677
|
|
@ -6,7 +6,6 @@ import { createClient } from '@supabase/supabase-js';
|
|||
|
||||
const supabaseUrl = import.meta.env.VITE_SUPABASE_URL;
|
||||
const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY;
|
||||
const supabaseServiceKey = import.meta.env.VITE_SUPABASE_SERVICE_ROLE_KEY;
|
||||
|
||||
const DATE_RANGES = [
|
||||
{ value: 'today', label: 'Сегодня' },
|
||||
|
|
@ -57,7 +56,7 @@ export default function ErrorLogPanel() {
|
|||
const [deleting, setDeleting] = useState(false);
|
||||
const intervalRef = useRef(null);
|
||||
const client = createClient(supabaseUrl, supabaseAnonKey);
|
||||
const adminClient = createClient(supabaseUrl, supabaseServiceKey);
|
||||
const client = createClient(supabaseUrl, supabaseAnonKey);
|
||||
|
||||
const getRangeStart = (range) => {
|
||||
const now = new Date();
|
||||
|
|
@ -141,7 +140,7 @@ export default function ErrorLogPanel() {
|
|||
if (selected.size === 0) return;
|
||||
if (!confirm(`Удалить ${selected.size} записей?`)) return;
|
||||
setDeleting(true);
|
||||
const { error: err } = await adminClient
|
||||
const { error: err } = await client
|
||||
.from('client_error_logs')
|
||||
.delete()
|
||||
.in('id', Array.from(selected));
|
||||
|
|
@ -153,7 +152,7 @@ export default function ErrorLogPanel() {
|
|||
const handleDeleteAll = async () => {
|
||||
if (!confirm('Удалить ВСЕ записи об ошибках? Это необратимо.')) return;
|
||||
setDeleting(true);
|
||||
const { error: err } = await adminClient
|
||||
const { error: err } = await client
|
||||
.from('client_error_logs')
|
||||
.delete()
|
||||
.neq('id', '00000000-0000-0000-0000-000000000000');
|
||||
|
|
@ -165,7 +164,7 @@ export default function ErrorLogPanel() {
|
|||
const handleDeleteOne = async (id) => {
|
||||
if (!confirm('Удалить эту запись?')) return;
|
||||
setDeleting(true);
|
||||
const { error: err } = await adminClient
|
||||
const { error: err } = await client
|
||||
.from('client_error_logs')
|
||||
.delete()
|
||||
.eq('id', id);
|
||||
|
|
|
|||
Loading…
Reference in New Issue