Home > Blockchain >  How can I access firestore data before authenticating phone number?
How can I access firestore data before authenticating phone number?

Time:09-27

In my flutter app I want to create a phone authentication for sign up, with one condition that only those phone numbers, which are already been stored in firestore database can sign up.. ..... How can I access firestore data before signing in?

CodePudding user response:

You can create a rule set for firebase access on the firebase application console.

This is a good place to look:

Firestore Security Rules Docs

CodePudding user response:

Register a blocking function for beforeCreate event and check that a user's phoneNumber is in a list of allowed numbers. If not throw an error.

Triggers before a new user is saved to the Firebase Authentication database, and before a token is returned to your client app.

const functions = require('firebase-functions');

exports.beforeCreate = functions.auth.user().beforeCreate((user, context) => {
  // TODO check user.phoneNumber againts allowed ones
});

See Extend Firebase Authentication with blocking Cloud Functions for details.

  • Related