Firebaseui-android: setAllowNewEmailAccounts(false) is not working as intended

Created on 13 Aug 2018  路  3Comments  路  Source: firebase/FirebaseUI-Android

I want to disable new account registrations via FirebaseUI. I found the method setAllowNewEmailAccounts in the SignInIntentBuilder but after setting it to false, I can still create new accounts

Intent builder = AuthUI.getInstance()
                .createSignInIntentBuilder()
                .setIsSmartLockEnabled(!BuildConfig.DEBUG, true)
                .setAllowNewEmailAccounts(false)
                .build();
        startActivityForResult(builder, LOG_IN_REQUEST_CODE);

Looking at the PR that introduced the feature, I can see the check was done in auth/src/main/java/com/firebase/ui/auth/ui/email/RegisterEmailActivity.java but I can't find that class in the library. Was this class nuked? is the switch to control the feature just left by mistake?

Most helpful comment

Ah, indeed, it works now. I didn't even know that there was a 4.X version

Using version 4.1.0 this works perfectly. The previous code in my OP didn't compile with 4.X. No setAllowNewAccounts in the SignInIntentBuilder. Now it's in the EmailBuilder. This did it for me
Intent loginIntent = AuthUI.getInstance() .createSignInIntentBuilder() .setIsSmartLockEnabled(!BuildConfig.DEBUG, true) .setAvailableProviders(Collections.singletonList(new EmailBuilder().setAllowNewAccounts(false).build())) .build(); startActivityForResult(loginIntent, LOG_IN_REQUEST_CODE);

Mind you, in the old version 3.3.1 the method is there but it's not working. Not sure if that branch is still supported

Thank you @SUPERCILEX

All 3 comments

No, it should work. I'd recommend upgrading to FUI 4.x. Check out the migration guide: https://github.com/firebase/FirebaseUI-Android/blob/master/docs/upgrade-to-4.0.md

Ah, indeed, it works now. I didn't even know that there was a 4.X version

Using version 4.1.0 this works perfectly. The previous code in my OP didn't compile with 4.X. No setAllowNewAccounts in the SignInIntentBuilder. Now it's in the EmailBuilder. This did it for me
Intent loginIntent = AuthUI.getInstance() .createSignInIntentBuilder() .setIsSmartLockEnabled(!BuildConfig.DEBUG, true) .setAvailableProviders(Collections.singletonList(new EmailBuilder().setAllowNewAccounts(false).build())) .build(); startActivityForResult(loginIntent, LOG_IN_REQUEST_CODE);

Mind you, in the old version 3.3.1 the method is there but it's not working. Not sure if that branch is still supported

Thank you @SUPERCILEX

yup its working

Was this page helpful?
0 / 5 - 0 ratings