【问题标题】:How to retrieve user auth information in cloud firestore using nodejs?如何使用 nodejs 在云 Firestore 中检索用户身份验证信息?
【发布时间】:2020-05-09 05:50:40
【问题描述】:

我正在尝试通过解析身份验证来获取用户信息。我有一个电话号码数组,我将它们传递给 auth 函数以获取用户,我能够做到这一点,但是当结果出现时,代码不会退出。而没有身份验证但我有电话号码的用户,我想返回一个虚拟对象。但我无法存在。这是我对验证码的尝试,phoneNumber 数组是电话号码数组。

const getAuth = async phoneNumber => {
  try {
    return await auth.getUserByPhoneNumber(phoneNumber);
  } catch (error) {
    if (error === 'auth/user-not-found') {
      console.log('this number is not auth');
    }
  }
};
const getAuth = async phoneNumber => {
  try {
    return authGrowthfile.getUserByPhoneNumber(phoneNumber);
  } catch (error) {
    if (error) {
      return {
        phoneNumber,
        uid: null,
        email: '',
        displayName: '',
        emailVerified: false,
        disabled: false,
      };
    }
  }
};

我这样调用这个函数:

const phoneNumberArray = ['+918888','+91798299']
const userRecord = await Promise.all(phoneNumberArray.map(getAuth))

【问题讨论】:

    标签: node.js firebase google-cloud-firestore google-cloud-functions


    【解决方案1】:

    你做得很好,你做的一切都是对的,只是一个简单的错字。

    const userRecord = await Promise.all(phoneNumberArray.map(phoneNumber => getAuth(phoneNumber)))
    

    【讨论】:

    • 我在 StackOverflow 上输入了这个,这就是类型错误的原因
    • 为什么你有两个getAuth 方法?
    • 我已经给出了我尝试过的两种方法,但过程没有退出
    • 仍然面临同样的问题,我认为有一些实例仍在幕后运行,这就是它不退出的原因
    猜你喜欢
    • 2018-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-04
    相关资源
    最近更新 更多