Logout works

all that needs doing now is 'save login'
This commit is contained in:
Felix 2019-07-16 11:42:34 +01:00
parent e3ca987aa8
commit fef1621d3e
No known key found for this signature in database
GPG key ID: 130EF6DC43E4DD07
4 changed files with 15 additions and 9 deletions

View file

@ -1,5 +1,5 @@
import 'dart:io';
import 'dart:async';
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
@ -16,12 +16,18 @@ Future<LoginModel> requestLogoutAPI(BuildContext context) async {
token = result;
});
Map<String, String> body = {
"Token":token,
};
final response = await http.post(
url,
headers: {HttpHeaders.authorizationHeader: "Token $token"},
body: json.encode(body),
);
if (response.statusCode == 200) {
debugPrint("Logout successful: " + response.body);
saveLogout();
return null;
} else {

View file

@ -62,10 +62,10 @@ Future<LoginModel> submitReceiptAPI(
print(responseJson[0]);
showDialogSingleButton(
context,
responseJson[0] == "" ? responseJson[0] : "Upload Successful",
"Transaction successfully submitted to server",
"OK"
context,
responseJson[0] == "" ? responseJson[0] : "Upload Successful",
"Transaction successfully submitted to server",
"OK"
);
return LoginModel.fromJson(responseJson);
} else {