This commit is contained in:
Phuoc Nguyen
2025-10-10 17:51:31 +07:00
parent 10ccd0300d
commit 77440ac957
7 changed files with 300 additions and 11 deletions

View File

@@ -127,6 +127,7 @@ class Auth extends _$Auth {
return result.fold(
(failure) {
print('❌ Login FAILED: ${failure.message}');
state = state.copyWith(
isAuthenticated: false,
isLoading: false,
@@ -135,12 +136,14 @@ class Auth extends _$Auth {
return false;
},
(authResponse) {
print('✅ Login SUCCESS: user=${authResponse.user.name}, token length=${authResponse.accessToken.length}');
state = AuthState(
user: authResponse.user,
isAuthenticated: true,
isLoading: false,
errorMessage: null,
);
print('✅ State updated: isAuthenticated=${state.isAuthenticated}');
return true;
},
);

View File

@@ -16,7 +16,7 @@ class AuthWrapper extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final authState = ref.watch(authProvider);
print('AuthWrapper build: isAuthenticated=${authState.isAuthenticated}, isLoading=${authState.isLoading}');
// Show loading indicator while checking auth status
if (authState.isLoading && authState.user == null) {
return const Scaffold(