Skip to content

Commit

Permalink
Fix icanteen support
Browse files Browse the repository at this point in the history
  • Loading branch information
vyPal committed Oct 31, 2023
1 parent 9ab9ae1 commit 407018c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 28 deletions.
23 changes: 9 additions & 14 deletions lib/icanteen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,19 @@ class ICanteenPageState extends State<ICanteenPage> {
loading = true; //make loading true to show progressindicator
});

String token = sharedPreferences.getString("token")!;

Response response = await dio
.get(
"$baseUrl/lunches",
options: buildCacheOptions(
const Duration(days: 0),
forceRefresh: true,
options: Options(
headers: {
"Authorization": "Bearer $token",
},
),
),
.post(
"$baseUrl/icanteen",
data: {
"username": sharedPreferences.getString("ic_email"),
"password": sharedPreferences.getString("ic_password"),
"server": sharedPreferences.getString("ic_server"),
},
options: Options(contentType: Headers.formUrlEncodedContentType),
)
.catchError((obj) {
return Response(
requestOptions: RequestOptions(path: "$baseUrl/lunches"),
requestOptions: RequestOptions(path: "$baseUrl/icanteen"),
statusCode: 500,
);
});
Expand Down
17 changes: 3 additions & 14 deletions lib/icanteen_setup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,9 @@ class ICanteenSetupScreenState extends State<ICanteenSetupScreen> {
setState(() {
hasLogin = true;
});
String? token = sharedPreferences.getString("token");
await dio.post(
"$baseUrl/set_icanteen",
data: {
'email': email,
'password': password,
'server': server,
},
options: Options(
headers: {
"Authorization": "Bearer $token",
},
),
);
sharedPreferences.setString("ic_server", server);
sharedPreferences.setString("ic_email", email);
sharedPreferences.setString("ic_password", password);
sharedPreferences.setBool("ice", true);
}

Expand Down
3 changes: 3 additions & 0 deletions lib/load.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ class LoadingScreenState extends State<LoadingScreen> {
baseUrl = endpoint;
}
quickstart = sharedPreferences.getBool('quickstart') ?? false;
if (sharedPreferences.getBool("ice") == true) {
sessionManager.set("iCanteenEnabled", true);
}
progress = 0.1;
loaderText = local!.loadCredentials;
dio.interceptors
Expand Down

0 comments on commit 407018c

Please sign in to comment.