这是indexloc提供的服务,不要输入任何密码
Skip to content

Currently not possible to use setAllowNewAccounts(false) with email/link authentication #1762

@theHilikus

Description

@theHilikus

It's currently not possible to create a user with the firebase admin sdk (or any other way outside of firebase UI) and have that user use email/link authentication. It seems that if you want to use email/link, you are forced to enable client registration (setAllowNewAccounts(true)), which is not always desirable.

I traced the code and the issue is that an externally created user always is created with a password provider id. This causes issues in com.firebase.ui.auth.util.data.ProviderUtils#fetchSortedProviders, which ends up throwing a developer error.

This is related to #1735 but there it was mentioned something slightly different: once you enable email/link, previous users with email/password won't be able to log in, meaning to use email/link, ALL users must use it, which looks like a design decision that requires a new feature to be improved. The situation here looks to me more like a bug: a completely new user that has never logged in cannot login at all, even if it is the first user in a blank auth db or all the users were created after enabling email/link auth. Also, the fact that the application accepts an invalid configuration (setAllowNewAccounts(false) with .enableEmailLinkSignIn(), which will never work together) also makes it look more like a corner-case bug

  • FirebaseUI version: 6.2.0

Steps to reproduce

  • Create a user outside of firebaseUI
  • Configure FirebaseUI with the following options
List<AuthUI.IdpConfig> providers = getAvailableProviders();
Intent loginIntent = AuthUI.getInstance()
                .createSignInIntentBuilder()
                .setAvailableProviders(providers)
                .build();
startActivityForResult(loginIntent, LOG_IN_REQUEST_CODE);

private List<AuthUI.IdpConfig> getAvailableProviders() {
        ActionCodeSettings actionCodeSettings = ActionCodeSettings.newBuilder()
                .setAndroidPackageName(BuildConfig.APPLICATION_ID, true, null)
                .setIOSBundleId(iOsBundleId)
                .setHandleCodeInApp(true)
                .setUrl("https://foo")
                .build();

        return Collections.singletonList(
                new EmailBuilder()
                        .setAllowNewAccounts(false)
                        .enableEmailLinkSignIn()
                        .setActionCodeSettings(actionCodeSettings)
                        .build());

    }
  • Try to log in. It will fail

Finally, all this worked fine if using pure firebase-auth: you can create a user externally and log it in using email/link

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions