Skip to content

Commit

Permalink
🐛 fixed route login api
Browse files Browse the repository at this point in the history
  • Loading branch information
julesartd committed Jun 2, 2024
1 parent 0f66d86 commit 2bfe220
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions frontend/app_student/.run/main.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="main" type="FlutterRunConfigurationType" factoryName="Flutter">
<option name="filePath" value="$PROJECT_DIR$/lib/main.dart" />
<method v="2" />
</configuration>
</component>
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class UserRepository {

Future<UserModel> 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},
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class SchoolSpacePageState extends State<SchoolSpacePage> {
appBar: HeaderLogo(appBarHeight: Global.screenHeight * 0.3),
body: BlocBuilder<UserCubit, UserState>(
builder: (context, state) {
print(state);
if (state is UserLoading) {
return const Center(
child: CircularProgressIndicator(),
Expand Down Expand Up @@ -98,7 +99,7 @@ class SchoolSpacePageState extends State<SchoolSpacePage> {
textColor: Colors.white,
);
});
return const SizedBox.shrink();
return Text(state.message);
} else {
return const SizedBox.shrink();
}
Expand Down
3 changes: 3 additions & 0 deletions frontend/app_student/lib/users/cubit/user_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ class UserCubit extends Cubit<UserState> {
emit(UserLoggedIn(user));
} catch (e) {
emit(UserError(e.toString()));
await Future.delayed(const Duration(seconds: 4));
UserModel user = await userRepository.getUser();
emit(UserWihtoutLink(user));
}
}
}

0 comments on commit 2bfe220

Please sign in to comment.