Check if an email already exists in Firebase Auth in Flutter App

后端 未结 2 848
北海茫月
北海茫月 2021-01-18 07:45

I\'m currently developing a flutter app that requires users to register before using it. I use Firebase Authentication and would like to check whether an email is already re

2条回答
  •  北海茫月
    2021-01-18 08:52

    I think the only possibility from within the app is attempting a login (signInWithEmailAndPassword) with that e-mail and check the result.

    If it's invalid password, the account exists. If it's invalid account, the account do not exist.

    Error 17011
    There is no user record corresponding to this identifier. The user may have been deleted
    Error 17009
    The password is invalid or the user does not have a password
    

    As this is a kind of an ugly solution, you can justify this additional call using it to check it the e-mail formatting is correct (according to the firebase rules). If it doesn't comply it will throw a address is badly formatted and you can alert the user soon enough.

    You can do these checks using the error codes with current versions of the plug-in.

提交回复
热议问题