feat(MED-131): check permissions for 'audit' schema

This commit is contained in:
2025-08-04 16:51:12 +03:00
parent 4b198cd10c
commit ff3335d331

View File

@@ -2,7 +2,7 @@
import { z } from 'zod'; import { z } from 'zod';
import { loadCurrentUserAccount } from '@/app/home/(user)/_lib/server/load-user-account'; import { loadCurrentUserAccount } from '@/app/home/(user)/_lib/server/load-user-account';
import { getSupabaseServerClient } from '@kit/supabase/server-client'; import { getSupabaseServerAdminClient } from '@kit/supabase/server-admin-client';
import { addToCart, deleteLineItem, retrieveCart } from '@lib/data/cart'; import { addToCart, deleteLineItem, retrieveCart } from '@lib/data/cart';
import { StoreCartLineItem, StoreProductVariant } from '@medusajs/types'; import { StoreCartLineItem, StoreProductVariant } from '@medusajs/types';
import { MontonioOrderHandlerService } from '@/packages/billing/montonio/src'; import { MontonioOrderHandlerService } from '@/packages/billing/montonio/src';
@@ -36,7 +36,6 @@ export async function handleAddToCart({
selectedVariant: StoreProductVariant selectedVariant: StoreProductVariant
countryCode: string countryCode: string
}) { }) {
const supabase = getSupabaseServerClient();
const user = await requireUserInServerComponent(); const user = await requireUserInServerComponent();
const account = await loadCurrentUserAccount() const account = await loadCurrentUserAccount()
if (!account) { if (!account) {
@@ -50,7 +49,7 @@ export async function handleAddToCart({
countryCode, countryCode,
}); });
const { error } = await supabase const { error } = await getSupabaseServerAdminClient()
.schema('audit') .schema('audit')
.from('cart_entries') .from('cart_entries')
.insert({ .insert({
@@ -68,7 +67,6 @@ export async function handleAddToCart({
} }
export async function handleNavigateToPayment({ language, paymentSessionId }: { language: string, paymentSessionId: string }) { export async function handleNavigateToPayment({ language, paymentSessionId }: { language: string, paymentSessionId: string }) {
const supabase = getSupabaseServerClient();
const user = await requireUserInServerComponent(); const user = await requireUserInServerComponent();
const account = await loadCurrentUserAccount() const account = await loadCurrentUserAccount()
if (!account) { if (!account) {
@@ -90,7 +88,7 @@ export async function handleNavigateToPayment({ language, paymentSessionId }: {
merchantReference: `${account.id}:${paymentSessionId}:${cart.id}`, merchantReference: `${account.id}:${paymentSessionId}:${cart.id}`,
}); });
const { error } = await supabase const { error } = await getSupabaseServerAdminClient()
.schema('audit') .schema('audit')
.from('cart_entries') .from('cart_entries')
.insert({ .insert({
@@ -111,7 +109,6 @@ export async function handleLineItemTimeout({
}: { }: {
lineItem: StoreCartLineItem lineItem: StoreCartLineItem
}) { }) {
const supabase = getSupabaseServerClient();
const user = await requireUserInServerComponent(); const user = await requireUserInServerComponent();
const account = await loadCurrentUserAccount() const account = await loadCurrentUserAccount()
if (!account) { if (!account) {
@@ -120,7 +117,7 @@ export async function handleLineItemTimeout({
await deleteLineItem(lineItem.id); await deleteLineItem(lineItem.id);
const { error } = await supabase const { error } = await getSupabaseServerAdminClient()
.schema('audit') .schema('audit')
.from('cart_entries') .from('cart_entries')
.insert({ .insert({