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 {
  var twitterLogin =
      TwitterLogin(consumerKey: consumerKey, consumerSecret: consumerSecret);
  final TwitterLoginResult result = await twitterLogin.authorize();
  switch (result.status) {
    case TwitterLoginStatus.loggedIn:
      var session = result.session;
      AuthCredential credential = TwitterAuthProvider.getCredential(
          authToken: session.token, authTokenSecret: session.secret);
      notify(context, "Processing ...");
      return FirebaseAuth.instance
          .signInWithCredential(credential)
          .then((result) => convert(result.user))
          .then((user) => Identity.of(context).user = user)
          .catchError(Identity.of(context).error);
      break;
    case TwitterLoginStatus.cancelledByUser:
    case TwitterLoginStatus.error:
      Identity.of(context).error(result.errorMessage);
      break;
  }
}