signOut method

  1. @override
Future<bool> signOut()
override

Implementation

@override
Future<bool> signOut() async {
  final MonitoringService monitoringService = core.get<MonitoringService>();
  var trace = await monitoringService.createTrace(name: 'signOut');
  trace.start();
  try {
    if (!isReady) {
      throw LittlefishFirebaseAuthException('AUTH_INIT_000',
          '$providerName: Firebase is not initialized, $providerName cannot sign out');
    }

    if (kCurrentUser == null) {
      logger.warning(
        this,
        "$providerName: User is not logged in, $providerName cannot sign out",
      );
      return true;
    }

    logger.debug(
      this,
      "$providerName: Signing out current user.",
    );

    await kInstance?.signOut();

    return true;
  } on FirebaseAuthException catch (e) {
    throw _handleFirebaseAuthException(e);
  } catch (e) {
    if (e is LittlefishException) {
      rethrow;
    }
    throw LittlefishFirebaseAuthException(
      'AUTH_014',
      'An unexpected error occurred during sign out.',
      cause: e,
    );
  } finally {
    trace.stop();
  }
}