mirror of
https://github.com/jjbrunton/Sauci.git
synced 2026-10-31 18:19:43 +00:00
Use RPC function for gift premium to fix RLS issues
This commit is contained in:
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();
|
||||||
|
|||||||
Reference in new issue
Block a user