mirror of
https://github.com/Dvorinka/1356.git
synced 2026-06-03 19:42:57 +00:00
small fix, don't worry about it
This commit is contained in:
@@ -1,17 +1,35 @@
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart' as supabase;
|
||||
|
||||
void initializeSupabaseClient() {
|
||||
// Additional client setup if needed
|
||||
// For now, we use the default Supabase.instance.client
|
||||
}
|
||||
|
||||
SupabaseClient get supabaseClient => Supabase.instance.client;
|
||||
supabase.SupabaseClient? get supabaseClient {
|
||||
try {
|
||||
return supabase.Supabase.instance.client;
|
||||
} catch (e) {
|
||||
// Supabase not initialized
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
bool get isSupabaseInitialized => supabaseClient != null;
|
||||
|
||||
supabase.User? get currentSupabaseUser {
|
||||
final client = supabaseClient;
|
||||
return client?.auth.currentUser;
|
||||
}
|
||||
|
||||
String? get currentSupabaseUserId => currentSupabaseUser?.id;
|
||||
|
||||
String? get currentSupabaseUserEmail => currentSupabaseUser?.email;
|
||||
|
||||
// Service role client for admin operations (like creating user profiles)
|
||||
// This should be used server-side or with proper security measures
|
||||
SupabaseClient? _serviceRoleClient;
|
||||
supabase.SupabaseClient? _serviceRoleClient;
|
||||
|
||||
SupabaseClient getServiceRoleClient() {
|
||||
supabase.SupabaseClient getServiceRoleClient() {
|
||||
if (_serviceRoleClient != null) return _serviceRoleClient!;
|
||||
|
||||
// Note: In a production app, the service role key should be stored securely
|
||||
@@ -22,12 +40,25 @@ SupabaseClient getServiceRoleClient() {
|
||||
const url = String.fromEnvironment('SUPABASE_URL');
|
||||
|
||||
if (serviceRoleKey.isNotEmpty && url.isNotEmpty) {
|
||||
_serviceRoleClient = SupabaseClient(url, serviceRoleKey);
|
||||
_serviceRoleClient = supabase.SupabaseClient(url, serviceRoleKey);
|
||||
return _serviceRoleClient!;
|
||||
}
|
||||
} catch (e) {
|
||||
// Service role key not available, will use regular client
|
||||
}
|
||||
|
||||
return supabaseClient;
|
||||
final client = supabaseClient;
|
||||
if (client != null) {
|
||||
return client;
|
||||
}
|
||||
|
||||
// If no client is available, throw an exception
|
||||
throw Exception('Supabase client not initialized');
|
||||
}
|
||||
|
||||
Future<void> signOutCurrentSupabaseUser() async {
|
||||
final client = supabaseClient;
|
||||
if (client == null) return;
|
||||
|
||||
await client.auth.signOut();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user