25-09-22/1
This commit is contained in:
@@ -99,8 +99,8 @@ class CRUD {
|
||||
return jsonData;
|
||||
} else {
|
||||
// Log API logical errors (e.g., "Customer not found")
|
||||
if (response.body == 'failure') {
|
||||
return 'failure';
|
||||
if (jsonData['status'] == 'failure') {
|
||||
// return 'failure';
|
||||
} else {
|
||||
addError(
|
||||
'API Logic Error: ${jsonData['status']}',
|
||||
@@ -122,6 +122,8 @@ class CRUD {
|
||||
} else if (response.statusCode == 401) {
|
||||
var jsonData = jsonDecode(response.body);
|
||||
if (jsonData['error'] == 'Token expired') {
|
||||
await Get.put(LoginController()).getJWT();
|
||||
// mySnackbarSuccess('please order now'.tr);
|
||||
return 'token_expired';
|
||||
} else {
|
||||
addError(
|
||||
@@ -161,10 +163,10 @@ class CRUD {
|
||||
Map<String, dynamic>? payload,
|
||||
}) async {
|
||||
String token = r(box.read(BoxName.jwt)).toString().split(Env.addd)[0];
|
||||
if (JwtDecoder.isExpired(token)) {
|
||||
await Get.put(LoginController()).getJWT();
|
||||
token = r(box.read(BoxName.jwt)).toString().split(Env.addd)[0];
|
||||
}
|
||||
// if (JwtDecoder.isExpired(token)) {
|
||||
// await Get.put(LoginController()).getJWT();
|
||||
// token = r(box.read(BoxName.jwt)).toString().split(Env.addd)[0];
|
||||
// }
|
||||
|
||||
final headers = {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
@@ -185,10 +187,10 @@ class CRUD {
|
||||
Map<String, dynamic>? payload,
|
||||
}) async {
|
||||
String token = r(box.read(BoxName.jwt)).toString().split(Env.addd)[0];
|
||||
if (JwtDecoder.isExpired(token)) {
|
||||
await Get.put(LoginController()).getJWT();
|
||||
token = r(box.read(BoxName.jwt)).toString().split(Env.addd)[0];
|
||||
}
|
||||
// if (JwtDecoder.isExpired(token)) {
|
||||
// await Get.put(LoginController()).getJWT();
|
||||
// token = r(box.read(BoxName.jwt)).toString().split(Env.addd)[0];
|
||||
// }
|
||||
|
||||
final headers = {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
|
||||
Reference in New Issue
Block a user