mirror of
https://github.com/Dvorinka/1356.git
synced 2026-06-03 19:42:57 +00:00
main, fix
This commit is contained in:
@@ -6,3 +6,28 @@ void initializeSupabaseClient() {
|
||||
}
|
||||
|
||||
SupabaseClient get supabaseClient => Supabase.instance.client;
|
||||
|
||||
// Service role client for admin operations (like creating user profiles)
|
||||
// This should be used server-side or with proper security measures
|
||||
SupabaseClient? _serviceRoleClient;
|
||||
|
||||
SupabaseClient getServiceRoleClient() {
|
||||
if (_serviceRoleClient != null) return _serviceRoleClient!;
|
||||
|
||||
// Note: In a production app, the service role key should be stored securely
|
||||
// This is typically handled server-side via Edge Functions or similar
|
||||
// For now, we'll fall back to the regular client if service role is not available
|
||||
try {
|
||||
const serviceRoleKey = String.fromEnvironment('SUPABASE_SERVICE_ROLE_KEY');
|
||||
const url = String.fromEnvironment('SUPABASE_URL');
|
||||
|
||||
if (serviceRoleKey.isNotEmpty && url.isNotEmpty) {
|
||||
_serviceRoleClient = SupabaseClient(url, serviceRoleKey);
|
||||
return _serviceRoleClient!;
|
||||
}
|
||||
} catch (e) {
|
||||
// Service role key not available, will use regular client
|
||||
}
|
||||
|
||||
return supabaseClient;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user