signOut method

Future<void> signOut(
  1. BuildContext context
)

Implementation

Future<void> signOut(BuildContext context) async {
  AuthenticatedUser? user = getCurrentUser();
  if (user != null) {
    // sign out with the Sign In Providers first
    if (user.provider == SignInProvider.firebase) {
      if (customFirebaseApp != null) {
        await FirebaseAuth.instanceFor(app: customFirebaseApp!).signOut();
      }
      // } else if (user.provider == SignInProvider.auth0) {
      //   await Auth0CredentialsManager().signOut();
    } else {
      // If we don't use the provider, sign out with the signIn clients
      if (user.client == SignInClient.google) {
        // TODO: save the instance of recreate the Google Sign In
        //await GoogleSignIn().signOut();
      } else if (user.client == SignInClient.apple) {
        // there is no sign out for Apple
      } else if (user.client == SignInClient.microsoft) {}
    }

    // then remove user from storage
    await _clearCurrentUser(context);
  }
}