doAttemptLogin method

  1. @override
Future<AuthResponse> doAttemptLogin(
  1. BuildContext context
)
override

Implementation

@override
Future<AuthResponse> doAttemptLogin(BuildContext context) async {
  try {
    try {
      final router = context.get<FRouter>();
      final route = router.matchRoute(routePath)!;
      assert(!route.isMissing,
          "You must provide a route /loginEmailPassword to use this login handler");

      final usernamePassword = await route.route!.openModal(context,
          expand: false,
          nestModals: true,
          constraints: loginModalConstraints(context));
      if (usernamePassword == null) {
        return AuthResponse.cancelled();
      }
      assert(usernamePassword is UserCredential,
          "The response from /loginEmailPassword must be UserCredential");
      var c = usernamePassword as fb.UserCredential;
      return c.user == null
          ? AuthResponse.cancelled()
          : AuthResponse.userLogin(user: c.user);
    } catch (e, stack) {
      _log.severe("Error from server: $e", e, stack);
      return AuthResponse.error(e);
    }
  } catch (e, stack) {
    _log.severe("Error from server: $e", e, stack);
    return AuthResponse.error("There was an error logging you in");
  }
}