Manter sessão e loading

This commit is contained in:
2026-05-08 11:53:18 +01:00
parent c1d1a0fce1
commit 490cdf5aab
5 changed files with 279 additions and 11 deletions

View File

@@ -1,4 +1,5 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'session_service.dart';
/// Service for handling Firebase Authentication
class AuthService {
@@ -90,12 +91,38 @@ class AuthService {
try {
print('DEBUG: Tentando fazer logout');
await _auth.signOut();
print('DEBUG: Logout realizado com sucesso');
// Clear saved session
await SessionService.clearSession();
print('DEBUG: Logout e limpeza de sessão realizados com sucesso');
} catch (e) {
print('DEBUG: Erro ao fazer logout: $e');
}
}
/// Attempt auto-login with saved credentials
static Future<bool> attemptAutoLogin() async {
try {
final sessionData = await SessionService.shouldAutoLogin();
if (sessionData['shouldAutoLogin'] == true) {
final email = sessionData['email'];
print('DEBUG: Attempting auto-login for: $email');
// Note: For security reasons, we cannot auto-login without password
// This method just checks if auto-login is available
// The actual login still requires user to enter password
return true;
}
return false;
} catch (e) {
print('DEBUG: Error in auto-login attempt: $e');
return false;
}
}
/// Get user-friendly error message
static String _getErrorMessage(String code) {
print('DEBUG: Processando código de erro: $code');