fix authentication provider

main
Mohammad Aljammal 5 years ago
parent 6933b6577f
commit 1187c3b605

@ -322,4 +322,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 649616dc336b3659ac6b2b25159d8e488e042b69
COCOAPODS: 1.10.0.rc.1
COCOAPODS: 1.10.1

@ -10,6 +10,7 @@ import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart';
import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:flutter/cupertino.dart';
import 'package:http/http.dart' as http;
import 'package:provider/provider.dart';
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
Helpers helpers = new Helpers();
@ -90,12 +91,6 @@ class BaseAppClient {
if (statusCode < 200 || statusCode >= 400) {
onFailure(Helpers.generateContactAdminMsg(), statusCode);
} else {
if(callLog){
callLog = false;
await AuthenticationViewModel().logout(isSessionTimeout: true);
}
var parsed = json.decode(response.body.toString());
if (parsed['ErrorType'] == 4) {
helpers.navigateToUpdatePage(parsed['ErrorEndUserMessage'],
@ -106,7 +101,7 @@ class BaseAppClient {
if (body['OTP_SendType'] != null) {
onFailure(getError(parsed), statusCode);
} else if (!isAllowAny) {
await AuthenticationViewModel().logout(isSessionTimeout: true);
await Provider.of<AuthenticationViewModel>(AppGlobal.CONTEX, listen: false).logout(isSessionTimeout: true);
Helpers.showErrorToast('Your session expired Please login again');
}
if (isAllowAny) {

@ -361,8 +361,7 @@ class AuthenticationViewModel extends BaseViewModel {
_firebaseMessaging.requestNotificationPermissions();
}
setState(ViewState.Busy);
_firebaseMessaging.getToken().then((String token) async {
var token = await _firebaseMessaging.getToken();
if (DEVICE_TOKEN == "" && !ProjectViewModel().isLogin) {
DEVICE_TOKEN = token;
@ -382,7 +381,6 @@ class AuthenticationViewModel extends BaseViewModel {
} else {
setState(ViewState.Idle);
}
});
}
/// determine the status of the app
@ -407,6 +405,7 @@ class AuthenticationViewModel extends BaseViewModel {
await Helpers.clearSharedPref();
sharedPref.setString(APP_Language, lang);
ProjectViewModel().isLogin = false;
deleteUser();
if(isSessionTimeout)
await getDeviceInfoFromFirebase();
Navigator.pushAndRemoveUntil(
@ -419,6 +418,7 @@ class AuthenticationViewModel extends BaseViewModel {
deleteUser(){
user = null;
unverified = false;
notifyListeners();
}

@ -172,7 +172,7 @@ class _AppDrawerState extends State<AppDrawer> {
),
onTap: () async {
Navigator.pop(context);
await AuthenticationViewModel().logout();
await authenticationViewModel.logout();
projectsProvider.isLogin = false;
},
),

Loading…
Cancel
Save