Use RPC function for gift premium to fix RLS issues

This commit is contained in:
jjbrunton committed 2026-01-16 18:41:21 +00:00
1 parent 0be833bba2
commit a558f5e67e
1 file changed
+4 -8
@@ -321,14 +321,10 @@ export function UserDetailPage() {
} }
expiresAt = date.toISOString(); expiresAt = date.toISOString();
} }
const { error } = await auditedSupabase.insert('subscriptions', { // Use RPC function which handles permissions internally
user_id: userId, const { error } = await supabase.rpc('admin_gift_premium', {
revenuecat_app_user_id: 'admin_grant', target_user_id: userId,
product_id: 'admin_premium', expires_at_param: expiresAt,
status: 'active',
store: 'manual',
purchased_at: new Date().toISOString(),
expires_at: expiresAt,
}); });
if (error) throw error; if (error) throw error;
const { data: updatedProfile } = await supabase.rpc('get_profile_with_auth_info', { user_id: userId }).single(); const { data: updatedProfile } = await supabase.rpc('get_profile_with_auth_info', { user_id: userId }).single();