当 AuthUI.getInstance().delete() 被调用时,AuthUI 删除了什么?

What is AuthUI deleting when AuthUI.getInstance().delete() is getting invoked?

我目前正在从我的应用程序中删除 FirebaseUI Auth,并将其替换为 "raw" Firebase Auth 代码。

现在我通过 GoogleSignInClient.silentSignIn()GoogleSignInClient.getSignInIntent() 登录 Google 登录 用户,并通过 GoogleSignInClient.signOut().

通过 FirebaseUser.delete() 删除 Firebase 用户时,我还需要调用 AuthUI.delete()。我假设 AuthUIFirebaseUI 的一部分,它为所有 OAuth 提供者提供了一个通用接口。在搜索等效项 GoogleSignInClient.delete() 时,我没有找到任何内容。

由于我将不再使用 FirebaseUI Auth,因此对 AuthUI.delete() 的调用将过时,但我想知道该调用执行了什么。与Google登录有关吗?我还需要删除一些东西吗?

AuthUI.delete()用于删除用户,并在一个方法调用中删除与该用户相关的所有提供者。源代码:

public Task<Void> delete(@NonNull Context context) {
        final FirebaseUser currentUser = mAuth.getCurrentUser();
        if (currentUser == null) {
            return Tasks.forException(new FirebaseAuthInvalidUserException(
                    String.valueOf(CommonStatusCodes.SIGN_IN_REQUIRED),
                    "No currently signed in user."));
        }

        final List<Credential> credentials = getCredentialsFromFirebaseUser(currentUser);
        final CredentialsClient client = GoogleApiUtils.getCredentialsClient(context);

        // Ensure the order in which tasks are executed properly destructures the user.
        return signOutIdps(context).continueWithTask(new Continuation<Void, Task<Void>>() {
            @Override
            public Task<Void> then(@NonNull Task<Void> task) {
                task.getResult(); // Propagate exception if there was one

                List<Task<?>> credentialTasks = new ArrayList<>();
                for (Credential credential : credentials) {
                    credentialTasks.add(client.delete(credential));
                }
                return Tasks.whenAll(credentialTasks)
                        .continueWith(new Continuation<Void, Void>() {
                            @Override
                            public Void then(@NonNull Task<Void> task) {
                                Exception e = task.getException();
                                Throwable t = e == null ? null : e.getCause();
                                if (!(t instanceof ApiException)
                                        || ((ApiException) t).getStatusCode() !=
                                        CommonStatusCodes.CANCELED) {
                                    // Only propagate the exception if it isn't an invalid account
                                    // one. This can occur if we failed to save the credential or it
                                    // was deleted elsewhere. However, a lack of stored credential
                                    // doesn't mean fully deleting the user failed.
                                    return task.getResult();
                                }

                                return null;
                            }
                        });
            }
        }).continueWithTask(new Continuation<Void, Task<Void>>() {
            @Override
            public Task<Void> then(@NonNull Task<Void> task) {
                task.getResult(); // Propagate exception if there was one
                return currentUser.delete();
            }
        });
    }

https://github.com/firebase/FirebaseUI-Android/blob/master/auth/src/main/java/com/firebase/ui/auth/AuthUI.java

如果您不想使用 AuthUI 并且想删除使用 Google 提供商登录的用户,那么首先您需要获取凭据,重新验证用户并删除。

例如:

AuthCredential credential = GoogleAuthProvider.getCredential(FirebaseAuth.getInstance().getCurrentUser().getUid(), null);
user.reauthenticate(credential).addOnCompleteListener...