lolocomotive/Klient

Wrong request in Initial Setup

Closed this issue · 3 comments

Hello,
After testing the app on my android phone (in debug mode) I encountered an error on the Initial Setup page on the third step:

I/flutter (27833): Instance of 'NetworkException403'
I/flutter (27833): #0      Client.default403Handler (package:kosmos_client/api/client.dart:150:5)
I/flutter (27833): #1      Client.request (package:kosmos_client/api/client.dart:279:9)
I/flutter (27833): <asynchronous suspension>
I/flutter (27833): #2      DatabaseManager.fetchGradesData (package:kosmos_client/api/database_manager.dart:202:24)
I/flutter (27833): <asynchronous suspension>
I/flutter (27833): #3      DatabaseManager.downloadAll (package:kosmos_client/api/database_manager.dart:62:7)
I/flutter (27833): <asynchronous suspension>

And after some debug I found that the requested URL was {{endpoint}}/consulterNotes/idetablissement/0/ which is of course a wrong URL, next we can look at the stacktrace and find that the request have been sent from the method fetchGradesData, and here we can find the code that caused this error:

final result = await Global.client!
            .request(Action.getGrades, params: [Global.client!.idEtablissement ?? '0']);

So the error is just that Global.client!.idEtablissement is null (I used a student account for testing). So I think that this problem can be solved just by doing a request to fetch the infoUtilisateur before this request.

After some additional research I found that there wasn't any request sent to infoutilisateur... even worse in it's definition in the Action class it was written with a typo. I will fork the project tomorrow to fix this issue and other ones that I found

Hello,
First of all thanks a lot for your interest in the app!
Throughout all my testing, I never provided any ideleve/idetablissement and everything worked fine, which is why I just set them to be constantly null. I was expecting this to cause problems when the app would be used with an account with multiple students attached to it (like a parent) but I don't understand why it doesn't work for you since you are using a student account.
The thing with solving this is that it would require new tables (for eleve / etablissement) in the database because there can be multiple students (and establishments) associated to a single account. Additionnally a way for the user to change the currently selected user/establishment would be necessary.
If you're not feeling like implementing all that, I can try testing with my parent's accounts and implement those feature myself. Let me know.

Yes I am already on the issue and I have a student and a parent account, I think that there is maybe a regression error in the state of your app that you are using for testing. But I am currently creating a patch to address this error that I will release today or tomorrow as fork