authenticate method

  1. @override
Future<void> authenticate (
  1. BuildContext context,
  2. [Map parameters]
)
override

Authenticate user

Implementation

@override
Future<void> authenticate(BuildContext context, [Map parameters]) async {
  assert(parameters != null);
  assert(parameters["link"] != null);
  final String link = parameters["link"];
  final bool isSignInEmailLink =
      await FirebaseAuth.instance.isSignInWithEmailLink(link);
  if (!isSignInEmailLink) {
    return notify(context,
        "The link is invalid. Please try again or contact for support.");
  }
  SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
  final String email = sharedPreferences.getString("email");

  notify(context, "Processing ...");
  return FirebaseAuth.instance
      .signInWithEmailAndLink(email: email, link: link)
      .then((result) => convert(result.user))
      .then((user) => Identity.of(context).user = user)
      .catchError(Identity.of(context).error);
}