Is it possible to enable Firebase email authentication but disable sign in?

前端 未结 3 606
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-21 20:12

In my app, I\'m already using the Firebase authentication with Google accounts, but I\'d also like to authorize some users who have no Google account. So I\'d like to manually a

相关标签:
3条回答
  • 2021-01-21 20:33

    I'm using passwordless Firebase Authentication and I hacked my way around this by using a callable cloud function that's triggered from my login form. The cloud function looks up the submitted email address in a whitelist firebase node and returns true or false. If true, do sign in. If false, I flash a "we're in closed beta" message.

    I add emails to the whitelist node both manually and from a form within a protected admin route in my app.

    0 讨论(0)
  • 2021-01-21 20:46

    I don't think this is possible who can sign in on an individual basis in Firebase Authentication.

    Typically sign in to Firebase is either open or closed for everyone. Then you allow them access to specific resources on an individual basis.

    For example, you use the Firebase Database or Cloud Firestore you could control access by having a whitelist of approved users in your security rules. See Restrict Firebase users by email

    Alternatively, you can set a custom claim on the profiles that you want to grant access, and check that in your security rules: Firebase Authentication with whitelisted email addresses

    0 讨论(0)
  • 2021-01-21 20:46

    Firebase Auth doesn't provide official tooling to limit email siginup to specific emails, or allow login but disable signup.

    The next best things you could do is

    • Write a cloud function to listen to user creation, and delete them as soon as they are created.
    • Assign custom claim token to the "approved" user account, and only provide access to these user with custom claim token.

    Below is a sample code which limit signup to specific emails https://code.luasoftware.com/tutorials/firebase/setup-firebase-authentication-with-vuejs/

    0 讨论(0)
提交回复
热议问题