|
|
|
@ -8,6 +8,7 @@ import 'package:http_interceptor/http_interceptor.dart';
|
|
|
|
|
|
|
|
|
|
import '../providers/auth_provider.dart';
|
|
|
|
|
import '../util/dr_app_shared_pref.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/config/config.dart';
|
|
|
|
|
|
|
|
|
|
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
|
|
|
|
|
List<String> publicUrls = [
|
|
|
|
@ -18,10 +19,9 @@ List<String> publicUrls = [
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
class HttpInterceptor extends InterceptorContract {
|
|
|
|
|
|
|
|
|
|
Client getClient(){
|
|
|
|
|
return HttpClientWithInterceptor.build(interceptors: [this]);
|
|
|
|
|
}
|
|
|
|
|
Client getClient() {
|
|
|
|
|
return HttpClientWithInterceptor.build(interceptors: [this]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<RequestData> interceptRequest({RequestData data}) async {
|
|
|
|
|
print('RequestData ${data.body}');
|
|
|
|
@ -29,26 +29,26 @@ class HttpInterceptor extends InterceptorContract {
|
|
|
|
|
try {
|
|
|
|
|
data.headers["Content-Type"] = "application/json";
|
|
|
|
|
data.headers["Accept"] = "application/json";
|
|
|
|
|
// if (publicUrls.contains(data.url)) {
|
|
|
|
|
// var loggedUserInfo = await sharedPref.getObj('loggedUser');
|
|
|
|
|
// var token = await sharedPref.getString(TOKEN);
|
|
|
|
|
// // print("token"+token);
|
|
|
|
|
// // print('loggedUserInfo${loggedUserInfo["LogInTokenID"]}');
|
|
|
|
|
// // // the sevices handel the token in differat name so I ask to be change
|
|
|
|
|
// // // we must change the imple
|
|
|
|
|
// var body = json.decode(data.body);
|
|
|
|
|
// body['LogInTokenID']=token;
|
|
|
|
|
// data.body = json.encode(body);
|
|
|
|
|
|
|
|
|
|
// // data.body['LogInTokenID'] = '';
|
|
|
|
|
// } else {
|
|
|
|
|
// if (data.body['LogInTokenID']) {
|
|
|
|
|
// data.body['LogInTokenID'] = '';
|
|
|
|
|
// }
|
|
|
|
|
// if (data.body['TokenID']) {
|
|
|
|
|
// data.body['TokenID'] = '';
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// if (publicUrls.contains(data.url)) {
|
|
|
|
|
// var loggedUserInfo = await sharedPref.getObj('loggedUser');
|
|
|
|
|
// var token = await sharedPref.getString(TOKEN);
|
|
|
|
|
// // print("token"+token);
|
|
|
|
|
// // print('loggedUserInfo${loggedUserInfo["LogInTokenID"]}');
|
|
|
|
|
// // // the sevices handel the token in differat name so I ask to be change
|
|
|
|
|
// // // we must change the imple
|
|
|
|
|
// var body = json.decode(data.body);
|
|
|
|
|
// body['LogInTokenID']=token;
|
|
|
|
|
// data.body = json.encode(body);
|
|
|
|
|
|
|
|
|
|
// // data.body['LogInTokenID'] = '';
|
|
|
|
|
// } else {
|
|
|
|
|
// if (data.body['LogInTokenID']) {
|
|
|
|
|
// data.body['LogInTokenID'] = '';
|
|
|
|
|
// }
|
|
|
|
|
// if (data.body['TokenID']) {
|
|
|
|
|
// data.body['TokenID'] = '';
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
} catch (e) {
|
|
|
|
|
print(e);
|
|
|
|
|
}
|
|
|
|
|