Mudanças em criar conta

This commit is contained in:
2026-05-08 12:37:15 +01:00
parent bf13bfd326
commit c821ce8e1e
4 changed files with 193 additions and 9 deletions

View File

@@ -21,12 +21,53 @@ class _StudentDashboardPageState extends State<StudentDashboardPage> {
_loadUserData();
}
void _loadUserData() {
final user = AuthService.currentUser;
if (user != null) {
setState(() {
_userName = user.displayName ?? 'Estudante';
});
@override
void didChangeDependencies() {
super.didChangeDependencies();
// Reload user data when dependencies change (e.g., after navigation)
_loadUserData();
}
Future<void> _loadUserData() async {
try {
final user = AuthService.currentUser;
if (user != null) {
print('DEBUG: Loading user data for dashboard');
print('DEBUG: User email: ${user.email}');
print('DEBUG: User displayName before reload: ${user.displayName}');
// Reload user data to get latest information from Firebase
await user.reload();
// Get the updated user
final updatedUser = AuthService.currentUser;
if (updatedUser != null) {
print(
'DEBUG: User displayName after reload: ${updatedUser.displayName}',
);
// Use displayName if available, otherwise use email part before @
String displayName = updatedUser.displayName ?? '';
print('DEBUG: Initial displayName value: "$displayName"');
if (displayName.isEmpty && updatedUser.email != null) {
// Extract name from email (e.g., "fabioceia0223@gmail.com" -> "fabioceia0223")
displayName = updatedUser.email!.split('@')[0];
print('DEBUG: Extracted name from email: "$displayName"');
}
if (displayName.isEmpty) {
displayName = 'Estudante';
print('DEBUG: Using fallback "Estudante"');
}
print('DEBUG: Final displayName to use: "$displayName"');
setState(() {
_userName = displayName;
});
}
}
} catch (e) {
print('DEBUG: Error loading user data: $e');
}
}