25
25
import com .facebook .login .LoginManager ;
26
26
import com .firebase .ui .auth .data .model .FlowParameters ;
27
27
import com .firebase .ui .auth .ui .idp .AuthMethodPickerActivity ;
28
- import com .firebase .ui .auth .util .CredentialUtils ;
29
28
import com .firebase .ui .auth .util .ExtraConstants ;
30
29
import com .firebase .ui .auth .util .GoogleApiUtils ;
31
30
import com .firebase .ui .auth .util .Preconditions ;
32
31
import com .firebase .ui .auth .util .data .PhoneNumberUtils ;
33
32
import com .firebase .ui .auth .util .data .ProviderAvailability ;
34
33
import com .firebase .ui .auth .util .data .ProviderUtils ;
35
- import com .google .android .gms .auth .api .credentials .Credential ;
36
- import com .google .android .gms .auth .api .credentials .CredentialRequest ;
37
- import com .google .android .gms .auth .api .credentials .CredentialsClient ;
38
34
import com .google .android .gms .auth .api .signin .GoogleSignIn ;
39
35
import com .google .android .gms .auth .api .signin .GoogleSignInAccount ;
40
36
import com .google .android .gms .auth .api .signin .GoogleSignInOptions ;
51
47
import com .google .firebase .auth .FacebookAuthProvider ;
52
48
import com .google .firebase .auth .FirebaseAuth ;
53
49
import com .google .firebase .auth .FirebaseAuthInvalidUserException ;
54
- import com .google .firebase .auth .FirebaseAuthProvider ;
55
50
import com .google .firebase .auth .FirebaseUser ;
56
51
import com .google .firebase .auth .GithubAuthProvider ;
57
52
import com .google .firebase .auth .GoogleAuthProvider ;
58
53
import com .google .firebase .auth .PhoneAuthProvider ;
59
54
import com .google .firebase .auth .TwitterAuthProvider ;
60
- import com .google .firebase .auth .UserInfo ;
61
55
62
56
import java .lang .annotation .Retention ;
63
57
import java .lang .annotation .RetentionPolicy ;
@@ -269,33 +263,35 @@ public static int getDefaultTheme() {
269
263
return R .style .FirebaseUI_DefaultMaterialTheme ;
270
264
}
271
265
272
- /**
273
- * Make a list of {@link Credential} from a FirebaseUser. Useful for deleting Credentials, not
274
- * for saving since we don't have access to the password.
275
- */
276
- private static List <Credential > getCredentialsFromFirebaseUser (@ NonNull FirebaseUser user ) {
277
- if (TextUtils .isEmpty (user .getEmail ()) && TextUtils .isEmpty (user .getPhoneNumber ())) {
278
- return Collections .emptyList ();
279
- }
280
-
281
- List <Credential > credentials = new ArrayList <>();
282
- for (UserInfo userInfo : user .getProviderData ()) {
283
- if (FirebaseAuthProvider .PROVIDER_ID .equals (userInfo .getProviderId ())) {
284
- continue ;
285
- }
286
-
287
- String type = ProviderUtils .providerIdToAccountType (userInfo .getProviderId ());
288
- if (type == null ) {
289
- // Since the account type is null, we've got an email credential. Adding a fake
290
- // password is the only way to tell Smart Lock that this is an email credential.
291
- credentials .add (CredentialUtils .buildCredentialOrThrow (user , "pass" , null ));
292
- } else {
293
- credentials .add (CredentialUtils .buildCredentialOrThrow (user , null , type ));
294
- }
295
- }
296
-
297
- return credentials ;
298
- }
266
+ // /**
267
+ // * Make a list of {@link Credential} from a FirebaseUser. Useful for deleting Credentials, not
268
+ // * for saving since we don't have access to the password.
269
+ // */
270
+ // private static List<Credential> getCredentialsFromFirebaseUser(@NonNull FirebaseUser user) {
271
+ // if (TextUtils.isEmpty(user.getEmail()) && TextUtils.isEmpty(user.getPhoneNumber())) {
272
+ // return Collections.emptyList();
273
+ // }
274
+ //
275
+ //
276
+ //
277
+ // List<Credential> credentials = new ArrayList<>();
278
+ // for (UserInfo userInfo : user.getProviderData()) {
279
+ // if (FirebaseAuthProvider.PROVIDER_ID.equals(userInfo.getProviderId())) {
280
+ // continue;
281
+ // }
282
+ //
283
+ // String type = ProviderUtils.providerIdToAccountType(userInfo.getProviderId());
284
+ // if (type == null) {
285
+ // // Since the account type is null, we've got an email credential. Adding a fake
286
+ // // password is the only way to tell Smart Lock that this is an email credential.
287
+ // credentials.add(CredentialUtils.buildCredentialOrThrow(user, "pass", null));
288
+ // } else {
289
+ // credentials.add(CredentialUtils.buildCredentialOrThrow(user, null, type));
290
+ // }
291
+ // }
292
+ //
293
+ // return credentials;
294
+ // }
299
295
300
296
/**
301
297
* Signs the user in without any UI if possible. If this operation fails, you can safely start a
@@ -344,38 +340,53 @@ public Task<AuthResult> silentSignIn(@NonNull Context context,
344
340
new FirebaseUiException (ErrorCodes .PLAY_SERVICES_UPDATE_CANCELLED ));
345
341
}
346
342
347
- return GoogleApiUtils .getCredentialsClient (context )
348
- .request (new CredentialRequest .Builder ()
349
- // We can support both email and Google at the same time here because they
350
- // are mutually exclusive. If a user signs in with Google, their email
351
- // account will automatically be upgraded (a.k.a. replaced) with the Google
352
- // one, meaning Smart Lock won't have to show the picker UI.
353
- .setPasswordLoginSupported (email != null )
354
- .setAccountTypes (google == null ? null :
355
- ProviderUtils .providerIdToAccountType (GoogleAuthProvider
356
- .PROVIDER_ID ))
357
- .build ())
358
- .continueWithTask (task -> {
359
- Credential credential = task .getResult ().getCredential ();
360
- String email1 = credential .getId ();
361
- String password = credential .getPassword ();
362
-
363
- if (TextUtils .isEmpty (password )) {
364
- return GoogleSignIn .getClient (appContext ,
365
- new GoogleSignInOptions .Builder (googleOptions )
366
- .setAccountName (email1 )
367
- .build ())
368
- .silentSignIn ()
369
- .continueWithTask (task1 -> {
370
- AuthCredential authCredential = GoogleAuthProvider
371
- .getCredential (
372
- task1 .getResult ().getIdToken (), null );
373
- return mAuth .signInWithCredential (authCredential );
374
- });
375
- } else {
376
- return mAuth .signInWithEmailAndPassword (email1 , password );
377
- }
378
- });
343
+ return null ;
344
+ //TODO(rosariopf): figure out how to do silent sign in for email/password
345
+ // return GoogleSignIn.getClient(appContext,
346
+ // new GoogleSignInOptions.Builder(googleOptions)
347
+ // .setAccountName(email)
348
+ // .build())
349
+ // .silentSignIn()
350
+ // .continueWithTask(task1 -> {
351
+ // AuthCredential authCredential = GoogleAuthProvider
352
+ // .getCredential(
353
+ // task1.getResult().getIdToken(), null);
354
+ // return mAuth.signInWithCredential(authCredential);
355
+ // });
356
+ //
357
+ // return GoogleApiUtils.getCredentialsClient(context)
358
+ // .request(new CredentialRequest.Builder()
359
+ // // We can support both email and Google at the same time here because they
360
+ // // are mutually exclusive. If a user signs in with Google, their email
361
+ // // account will automatically be upgraded (a.k.a. replaced) with the Google
362
+ // // one, meaning Smart Lock won't have to show the picker UI.
363
+ // .setPasswordLoginSupported(email != null)
364
+ // .setAccountTypes(google == null ? null :
365
+ // ProviderUtils.providerIdToAccountType(GoogleAuthProvider
366
+ // .PROVIDER_ID))
367
+ // .build()
368
+ // )
369
+ // .continueWithTask(task -> {
370
+ // Credential credential = task.getResult().getCredential();
371
+ // String email1 = credential.getId();
372
+ // String password = credential.getPassword();
373
+ //
374
+ // if (TextUtils.isEmpty(password)) {
375
+ // return GoogleSignIn.getClient(appContext,
376
+ // new GoogleSignInOptions.Builder(googleOptions)
377
+ // .setAccountName(email1)
378
+ // .build())
379
+ // .silentSignIn()
380
+ // .continueWithTask(task1 -> {
381
+ // AuthCredential authCredential = GoogleAuthProvider
382
+ // .getCredential(
383
+ // task1.getResult().getIdToken(), null);
384
+ // return mAuth.signInWithCredential(authCredential);
385
+ // });
386
+ // } else {
387
+ // return mAuth.signInWithEmailAndPassword(email1, password);
388
+ // }
389
+ // });
379
390
}
380
391
381
392
/**
@@ -393,9 +404,10 @@ public Task<Void> signOut(@NonNull Context context) {
393
404
Log .w (TAG , "Google Play services not available during signOut" );
394
405
}
395
406
396
- Task <Void > maybeDisableAutoSignIn = playServicesAvailable
397
- ? GoogleApiUtils .getCredentialsClient (context ).disableAutoSignIn ()
398
- : Tasks .forResult ((Void ) null );
407
+ // TODO: Uncomment this
408
+ Task <Void > maybeDisableAutoSignIn =
409
+ // playServicesAvailable ? GoogleApiUtils.getCredentialsClient(context).disableAutoSignIn() :
410
+ Tasks .forResult ((Void ) null );
399
411
400
412
maybeDisableAutoSignIn
401
413
.continueWith (task -> {
@@ -440,7 +452,8 @@ public Task<Void> delete(@NonNull final Context context) {
440
452
"No currently signed in user." ));
441
453
}
442
454
443
- final List <Credential > credentials = getCredentialsFromFirebaseUser (currentUser );
455
+ // TODO(rosariopf): Find a way to delete credentials
456
+ // final List<Credential> credentials = getCredentialsFromFirebaseUser(currentUser);
444
457
445
458
// Ensure the order in which tasks are executed properly destructures the user.
446
459
return signOutIdps (context ).continueWithTask (task -> {
@@ -451,11 +464,11 @@ public Task<Void> delete(@NonNull final Context context) {
451
464
return Tasks .forResult ((Void ) null );
452
465
}
453
466
454
- final CredentialsClient client = GoogleApiUtils .getCredentialsClient (context );
467
+ // final CredentialsClient client = GoogleApiUtils.getCredentialsClient(context);
455
468
List <Task <?>> credentialTasks = new ArrayList <>();
456
- for (Credential credential : credentials ) {
457
- credentialTasks .add (client .delete (credential ));
458
- }
469
+ // for (Credential credential : credentials) {
470
+ // credentialTasks.add(client.delete(credential));
471
+ // }
459
472
return Tasks .whenAll (credentialTasks )
460
473
.continueWith (task1 -> {
461
474
Exception e = task1 .getException ();
0 commit comments