save login works
This commit is contained in:
parent
4c036b8bf2
commit
c288f257c5
7 changed files with 51 additions and 16 deletions
|
@ -20,14 +20,14 @@ Future<LoginModel> requestLoginAPI(
|
|||
'password': password,
|
||||
};
|
||||
|
||||
debugPrint('$body');
|
||||
// debugPrint('$body');
|
||||
|
||||
final response = await http.post(
|
||||
url,
|
||||
body: json.encode(body),
|
||||
);
|
||||
|
||||
debugPrint(response.body);
|
||||
// debugPrint(response.body);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final responseJson = json.decode(response.body);
|
||||
|
@ -38,17 +38,18 @@ Future<LoginModel> requestLoginAPI(
|
|||
|
||||
return LoginModel.fromJson(responseJson);
|
||||
} else {
|
||||
debugPrint("Invalid, either creds are wrong or server is down");
|
||||
Navigator.of(context).pushReplacementNamed('/HomePage'); // just here temporarily while server is down
|
||||
// debugPrint("Invalid, either credentials are wrong or server is down");
|
||||
|
||||
final responseJson = json.decode(response.body);
|
||||
|
||||
saveCurrentLogin(responseJson, body["email"]);
|
||||
|
||||
showDialogSingleButton(
|
||||
context,
|
||||
"Unable to Login",
|
||||
"You may have supplied an invalid 'Email' / 'Password' combination. Please try again or email an administrator.",
|
||||
"OK");
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,12 +26,12 @@ Future<LoginModel> requestLogoutAPI(BuildContext context) async {
|
|||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
debugPrint("Logout successful: " + response.body);
|
||||
// debugPrint("Logout successful: " + response.body);
|
||||
|
||||
saveLogout();
|
||||
return null;
|
||||
} else {
|
||||
debugPrint("Logout unsuccessful: " + response.body);
|
||||
// debugPrint("Logout unsuccessful: " + response.body);
|
||||
|
||||
saveLogout();
|
||||
return null;
|
||||
|
|
|
@ -46,20 +46,20 @@ Future<LoginModel> submitReceiptAPI(
|
|||
'session_key': preferences.get('LastToken'),
|
||||
};
|
||||
|
||||
debugPrint('$body');
|
||||
debugPrint(json.encode(body));
|
||||
// debugPrint('$body');
|
||||
// debugPrint(json.encode(body));
|
||||
|
||||
final response = await http.post(
|
||||
url,
|
||||
body: json.encode(body),
|
||||
);
|
||||
|
||||
debugPrint(response.body);
|
||||
// debugPrint(response.body);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final responseJson = json.decode(response.body);
|
||||
|
||||
print(responseJson[0]);
|
||||
// print(responseJson[0]);
|
||||
|
||||
showDialogSingleButton(
|
||||
context,
|
||||
|
|
Reference in a new issue