Firebase Auth using phone number and password

前端 未结 4 1382
抹茶落季
抹茶落季 2021-02-04 14:11

I am developing Android app using Firebase. Because of that, I want to use Firebase Auth. I have following requirements:

  • Register/Log in using Facebook
  • Re
相关标签:
4条回答
  • 2021-02-04 14:48

    I had a similar problem - I combined firebase auth(email + password) with (phone+otp) to get phone+password auth -

    https://medium.com/@shivampesitbng/firebase-phone-password-auth-in-vue-b94f15b8fb3d

    0 讨论(0)
  • 2021-02-04 14:51

    Firebase phone authentication is using OTP(one time password). This way there is no hassle for the user to remember the password. Once authenticated, you will be registered. The sms code acts as a password. But that is for one time. Usually , users prefer such behaviour in which you dont have to remember the passwords. If you are still looking for the way you want, see this link and create a custom authentication method. https://firebase.google.com/docs/auth/android/custom-auth

    0 讨论(0)
  • 2021-02-04 14:52

    If you have both email and phone of your user and you can use Admin SDK, then perhaps you could exchange users phone number to his email and login with email and password in the background.

    Something like this (node.js)

    admin.auth().getUserByPhoneNumber(phoneNumber)
        .then(user => {
            firebase.auth().signInWithEmailAndPassword(user.email, password);
        });
    
    0 讨论(0)
  • 2021-02-04 14:55

    Use Fake Email:

    Well, Firebase doesn't support sign in with mobile number and password but it supports email and password. So you can create a fake email with your mobile number.

    Ie: 78******69@yourdomain.com

    Also, you can create a complete Authentication system using it.

    Registration:

    • Input user mobile and password and proceed to the next page.

    • Now use Firebase Phone Auth (OTP) to createUser. If process success, link fake email, password credentials in background.

      AuthCredential credential = EmailAuthProvider.getCredentialWithLink(email, emailLink); auth.getCurrentUser().linkWithCredential(credential);

    Login:

    • Input mobile and password to login. Convert the mobile in fake email and then signInWithEmailAndPassword().

    Forget Password:

    • Redirect the user to a new Page and user Phone Auth to verify the user. If successful, input a new password and change the password of the Email Auth.
    0 讨论(0)
提交回复
热议问题