wipeAndReinstall method

Future<void> wipeAndReinstall()

Implementation

Future<void> wipeAndReinstall() async {
  // If I would be logged in > logout (to give the user opportunity to select the user in the signIn)
  await AbstractMainRepositorySingleton.singleton.userRepository()!.signOut();
  var usr = await (AbstractMainRepositorySingleton.singleton
      .userRepository()!
      .signInWithGoogle());
  if (usr == null) {
    throw Exception("User is null");
  }
  await claimOwnerShipApplication(theApp.documentID, usr.uid);

  member = await AccessBloc.firebaseToMemberModel(usr);
  if (member == null) {
    print(
        'Can not register $theApp.documentID because member cannot be created');
  } else {
    memberClaimRepository()!.listenTo(member!.documentID, (value) async {
      await usr.reload();
      await usr.getIdTokenResult(true);
    });

    await claimAccess(theApp.documentID, usr.uid);

    await run(usr.uid);
    print('Installed $theApp.documentID successfully');
  }
}