From 2bfe220f1b752d641356a1da71ad90254f61ec80 Mon Sep 17 00:00:00 2001 From: Jules Artaud Date: Sun, 2 Jun 2024 19:38:12 +0200 Subject: [PATCH] :bug: fixed route login api --- frontend/app_student/.run/main.run.xml | 6 ++++++ .../lib/api/users/repositories/user_repository.dart | 2 +- .../lib/school_space/views/school_space_page.dart | 3 ++- frontend/app_student/lib/users/cubit/user_cubit.dart | 3 +++ 4 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 frontend/app_student/.run/main.run.xml diff --git a/frontend/app_student/.run/main.run.xml b/frontend/app_student/.run/main.run.xml new file mode 100644 index 0000000..b5c260e --- /dev/null +++ b/frontend/app_student/.run/main.run.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/frontend/app_student/lib/api/users/repositories/user_repository.dart b/frontend/app_student/lib/api/users/repositories/user_repository.dart index ec294fb..9506243 100644 --- a/frontend/app_student/lib/api/users/repositories/user_repository.dart +++ b/frontend/app_student/lib/api/users/repositories/user_repository.dart @@ -57,7 +57,7 @@ class UserRepository { Future login(String ine, String birthDate) async { final response = await http.post( - Uri.parse('${apiService.apiUrl}/api/student/login'), + Uri.parse('${apiService.apiUrl}/api/login'), body: {'username': ine, 'password': birthDate}, ); diff --git a/frontend/app_student/lib/school_space/views/school_space_page.dart b/frontend/app_student/lib/school_space/views/school_space_page.dart index 7306f9d..6bb51be 100644 --- a/frontend/app_student/lib/school_space/views/school_space_page.dart +++ b/frontend/app_student/lib/school_space/views/school_space_page.dart @@ -29,6 +29,7 @@ class SchoolSpacePageState extends State { appBar: HeaderLogo(appBarHeight: Global.screenHeight * 0.3), body: BlocBuilder( builder: (context, state) { + print(state); if (state is UserLoading) { return const Center( child: CircularProgressIndicator(), @@ -98,7 +99,7 @@ class SchoolSpacePageState extends State { textColor: Colors.white, ); }); - return const SizedBox.shrink(); + return Text(state.message); } else { return const SizedBox.shrink(); } diff --git a/frontend/app_student/lib/users/cubit/user_cubit.dart b/frontend/app_student/lib/users/cubit/user_cubit.dart index c0628c6..3e96610 100644 --- a/frontend/app_student/lib/users/cubit/user_cubit.dart +++ b/frontend/app_student/lib/users/cubit/user_cubit.dart @@ -103,6 +103,9 @@ class UserCubit extends Cubit { emit(UserLoggedIn(user)); } catch (e) { emit(UserError(e.toString())); + await Future.delayed(const Duration(seconds: 4)); + UserModel user = await userRepository.getUser(); + emit(UserWihtoutLink(user)); } } }