checkExistFirebaseLoginSession method

Future<bool> checkExistFirebaseLoginSession()

Implementation

Future<bool> checkExistFirebaseLoginSession() async {
  final token = await wepinStorage.getLocalStorage<IFirebaseWepin>(StorageDataType.firebaseWepin);
  if (token != null) {
    try {
      final response = await wepinFirebaseNetwork.getRefreshIdToken(GetRefreshIdTokenRequest(refreshToken: token.refreshToken));

      final newToken = IFirebaseWepin(
        provider: token.provider,
        idToken: response.idToken,
        refreshToken: token.refreshToken,
      );
      await wepinStorage.setLocalStorage<IFirebaseWepin>('firebase:wepin', newToken);

      return true;
    } catch (error) {
      await clearSession();
      return false;
    }
  } else {
    await clearSession();
    return false;
  }
}